Skip to content

Instantly share code, notes, and snippets.

@shubhamnikam
Created September 3, 2018 12:35
Show Gist options
  • Save shubhamnikam/bc411f4337b0ca1be8659b4f8872d4f4 to your computer and use it in GitHub Desktop.
Save shubhamnikam/bc411f4337b0ca1be8659b4f8872d4f4 to your computer and use it in GitHub Desktop.
Implicit Intent - SMS
intentSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
String phoneNumber = "1234567890";
String message = "hey there...";
intent.setData(Uri.parse("smsto:" + phoneNumber));
intent.putExtra("sms_body", message);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment