Skip to content

Instantly share code, notes, and snippets.

View Try64's full-sized avatar
🎯
Focusing

MSI Abu Zafar Newton Try64

🎯
Focusing
View GitHub Profile
@Try64
Try64 / openSMSClientWithData
Last active May 1, 2021 15:31
JAVA Method to open SMS app with Data or Show Toast on Error for Android
public void openSMSClientWithData(@NotNull String phoneNumberWithCountryCode,
@NotNull String smsBody,
@NotNull Context contextForToastMessage) {
Uri smsUri = Uri.parse("smsto:" + phoneNumberWithCountryCode);
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, smsUri);
smsIntent.putExtra("sms_body", smsBody);
try {
startActivity(smsIntent);
} catch (Exception ex) {