android - 双卡手机短信管理器?

标签 android

我正在使用 SMS Manager 在 android 中发送短信。我使用的代码如下:

private void sendSms(String Phnno, String Message) {
    if (Utils.checkSIM(MyActivity.this)) {
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(Phnno, null, Message, null, null);
        Utils.showMessage(MyActivity.this,"","Thank You for your interest,please check your inbox for the results.");

    } else {
        showErrorMessage(MyActivity.this, "SIM Error!",
                "Please insert SIM");
    }

}

此代码在单卡手机上非常适合我,但是当我在双卡手机中检查此代码时,我收到以下警告并且永远不会发送短信。

01-11 15:56:13.664: W/sendTextMessage(6656): use single sim interface to sendTextMessage by double sim interface

请建议我如何在我的双卡手机上实现它。提前致谢。

最佳答案

这两种情况都适用。如果用户已经选择了默认的 sim 卡,它将自动接受并转到下一个过程,否则在单击发送按钮时,它会要求确认选择任何 sim 卡以发送短信。我们已经测试了它的工作正常。

示例源代码:

try 
{    
     Intent sendIntent = new Intent(Intent.ACTION_VIEW);
     sendIntent.putExtra("sms_body","Body");
     sendIntent.putExtra("address", "PhoneNumber");
     sendIntent.setType("vnd.android-dir/mms-sms");
     startActivity(sendIntent);
} 
catch (Exception e) 
{
     Toast.makeText(getApplicationContext(),"SMS faild, please try again later!",Toast.LENGTH_SHORT).show();
     e.printStackTrace();
}

关于android - 双卡手机短信管理器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14276328/

相关文章:

android - 为什么在使用 InstrumentationRegistry.getContext().getString() 时会出现 Resources$NotFoundException?

android - 在 GPX 或 KML 中指定精度

android - 如何使用 Eclipse 获取模拟器截图?

android - 如何通过 Android Studio 对动态功能模块执行 UI 测试?

android - Room API - 如何检索最近插入的实体生成 id?

android - 将字节码转换为 dex 时出错 : DexException: Library dex files are not supported in multi-dex mode

java - 更改 PopupWindow 中 TextView 的文本不起作用

android - 如何在android中的 map 上添加动画图钉?

Android 应用程序链接到动态功能显示应用程序选择器对话框显示同一应用程序两次

android - 是否可以用 && 比较两个 bool 值?