After google policy changed to not use SEND_SMS. I am using sms intent to send sms with custom message and sender address auto populated. It work in almost all mobile. But only in oneplus mobiles, receipent address is not getting populated
private void sendSMS(String phoneNumber, String message) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
{
String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(getActivity());
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.putExtra("address",phoneNumber);
sendIntent.putExtra("exit_on_sent", true);
if (defaultSmsPackageName != null)
{
sendIntent.setPackage(defaultSmsPackageName);
}
startActivity(sendIntent);
}
else
{
Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address",phoneNumber);
smsIntent.putExtra("sms_body",message);
startActivity(smsIntent);
}
}
I also tried
Intent sendIntent =new Intent(Intent.ACTION_VIEW);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.putExtra("address",phoneNumber);
sendIntent.putExtra("exit_on_sent", true);
sendIntent.setData(Uri.parse("smsto:" + phoneNumber));
and
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("address", phoneNumber);
intent.putExtra("sms_body", message);
intent.setData(Uri.parse("smsto:" + phoneNumber));
intent.putExtra("exit_on_sent", true);
None are working in oneplus mobiles(3, 7 and 7 pro). It is working in all MI phone, Samsung, Nokia, Honor, Motorola, Lenovo etc. Only in oneplus phone having issue.
from SMS Intent not populating recipient only in oneplus mobiles
No comments:
Post a Comment