android - 短信应用程序 Intent 在 android 3.0 及更高版本中不起作用

标签 android sms android-3.0-honeycomb

这是我用来调用 SMS 应用程序的代码 fragment :

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 的设备上,上面的代码工作正常,SMS 页面被打开,要发送的消息和号码被正确预填充,但在 Android 3.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);

关于android - 短信应用程序 Intent 在 android 3.0 及更高版本中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10664372/

相关文章:

c# - 适用于 Windows + C# 的短信网关

python - Tp-Link M7350 4G LTE 路由器 - 使用带有 Raspberry Pi 的 python 脚本发送短信

android - Fragments如何影响Activity "single, focused thing that the user can do"原理?

Android Fragments API 无法正确显示背景 9patch 图像

android - react native ffmpeg : Native module cannot be null (ios) and null is not an object (evaluating 'RNFFmpegModule.enableLogEvents' ) (android)

android - 如何在android中打开设备管理员设置?

java - 如何提取字母数字字符串中的前四位连续数字?

ios - 当 iOS 应用程序在后台挂起时,自动返回到该应用程序。

android - 替换最近应用程序菜单中的图像

android - 如何对齐第一个元素填充所有可用空间的 2 个元素?