这是我用来调用sms应用程序的代码:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
intent.putExtra("sms_body", body);
intent.putExtra("compose_mode", true);
launchIntent(intent);
在操作系统版本低于android 3.0的设备上,上面的代码运行良好,短信页面打开,要发送的消息和号码被正确地预填充,但在android3.0和更高版本的设备上,这不再工作。
在android 3.0中,sms intent被调用,数字被填充,而不是文本,在android 4.0中,sms intent被调用,文本被填充,而不是数字。
有人知道这个问题的解决办法吗?
最佳答案
此代码适用于所有版本的android
String smsBody = Resources.getString("InvitationBody", getBaseContext()) + Local.User.FirstName;
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", smsBody);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);