【问题标题】:How to send a SMS in android? [duplicate]如何在android中发送短信? [复制]
【发布时间】:2015-01-13 11:46:47
【问题描述】:

我想向用户发送短信作为通知。我们如何向特定的手机号码发送短信。 还请说明将使用哪种服务发送短信。

【问题讨论】:

    标签: android sms


    【解决方案1】:

    在 Android 中,您可以使用SmsManager API 或设备的Built-in SMS 应用程序发送短信。

    例如:

    SmsManager API

    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
    

    内置短信应用

      Intent sendIntent = new Intent(Intent.ACTION_VIEW);
      sendIntent.putExtra("sms_body", "default content");
      sendIntent.setType("vnd.android-dir/mms-sms");
      startActivity(sendIntent);
    

    两者都需要SEND_SMS 权限。

    <uses-permission android:name="android.permission.SEND_SMS" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2011-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-21
      • 2013-08-20
      相关资源
      最近更新 更多