Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PostPad在android中发送短信_Android_Sms_Smsmanager - Fatal编程技术网

使用PostPad在android中发送短信

使用PostPad在android中发送短信,android,sms,smsmanager,Android,Sms,Smsmanager,我在android中使用SmsManager发送消息。使用预付费号码时,此应用在我的设备上运行正常。但当我使用后付费号码时,我无法发送信息。预付费和后付费号码是否与在android中发送消息有关。请帮助。但是,我发现如果消息数超过160,sms.sendTextMessage()将无法工作。例如,您必须将消息分成多个部分,然后使用sms.sendMultiPartTextMessage()。只有英文字符将是Hii感谢宝贵的信息。我得到了答案。预付费或后付费在通过smsManager发送邮件时并不

我在android中使用SmsManager发送消息。使用预付费号码时,此应用在我的设备上运行正常。但当我使用后付费号码时,我无法发送信息。预付费和后付费号码是否与在android中发送消息有关。请帮助。

但是,我发现如果消息数超过160,sms.sendTextMessage()将无法工作。例如,您必须将消息分成多个部分,然后使用sms.sendMultiPartTextMessage()。只有英文字符将是Hii感谢宝贵的信息。我得到了答案。预付费或后付费在通过smsManager发送邮件时并不重要。
private void sendSMS(String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";

PendingIntent sentPI = PendingIntent.getBroadcast(act, 0, new Intent(
        SENT), 0);

PendingIntent deliveredPI = PendingIntent.getBroadcast(act, 0,
        new Intent(DELIVERED), 0);

if (message.length() <= 70) {
    SmsManager sms = SmsManager.getDefault();
    Log.d(LOG_TAG, "Send Sms : " + message + " serverNumber "
            + phoneNumber);
    sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
} else {
    SmsManager sms = SmsManager.getDefault();
    ArrayList<String> parts = sms.divideMessage(message);
    int numParts = parts.size();

    ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
    ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();

    for (int i = 0; i < numParts; i++) {
        sentIntents.add(PendingIntent.getBroadcast(act, 0, new Intent(
                SENT), 0));
        deliveryIntents.add(PendingIntent.getBroadcast(act, 0,
                new Intent(DELIVERED), 0));
    }
    Log.d(LOG_TAG, "Send Sms multipart : " + message + " serverNumber "
            + phoneNumber);
    sms.sendMultipartTextMessage(phoneNumber, null, parts, sentIntents,
            deliveryIntents);
}