Java Code Examples for android.telephony.SmsManager#divideMessage()

The following examples show how to use android.telephony.SmsManager#divideMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GpsSearch.java    From Finder with GNU General Public License v3.0 6 votes vote down vote up
private void start_send() {   //sending to all who asked
    if ((Build.VERSION.SDK_INT >= 23 &&
            (getApplicationContext().checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED)) ||
            Build.VERSION.SDK_INT < 23) {
        //adding battery data
        IntentFilter bat_filt= new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        Intent battery = getApplicationContext().registerReceiver(null, bat_filt);
        int level = battery.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        int scale = battery.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
        float batteryPct = level / (float) scale;
        String batLevel = String.valueOf(Math.round(batteryPct*100));
        sms_answer.append(" bat:");
        sms_answer.append(batLevel);
        sms_answer.append("%\n");

        SmsManager sManager = SmsManager.getDefault();
        ArrayList<String> parts = sManager.divideMessage(sms_answer.toString());
        for (String number : phones) {
            sManager.sendMultipartTextMessage(number, null, parts, null,null);
        }
    }

    stopSelf();
}
 
Example 2
Source File: PhoneUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 发送短信
 * @param phoneNumber 接收号码
 * @param content     短信内容
 * @return {@code true} success, {@code false} fail
 */
@RequiresPermission(android.Manifest.permission.SEND_SMS)
public static boolean sendSmsSilent(final String phoneNumber, final String content) {
    if (TextUtils.isEmpty(content)) return false;
    try {
        PendingIntent sentIntent = PendingIntent.getBroadcast(DevUtils.getContext(), 0, new Intent("send"), 0);
        SmsManager smsManager = SmsManager.getDefault();
        if (content.length() >= 70) {
            List<String> ms = smsManager.divideMessage(content);
            for (String str : ms) {
                smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
            }
        } else {
            smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
        }
        return true;
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "sendSmsSilent");
    }
    return false;
}
 
Example 3
Source File: SmsSenderService.java    From RememBirthday with GNU General Public License v3.0 6 votes vote down vote up
private void sendSms(AutoSms sms, boolean deliveryReports) {
    ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
    ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();
    PendingIntent sentPendingIntent = getPendingIntent(sms.getDateCreated().getTime(), SmsSentReceiver.class);
    PendingIntent deliveredPendingIntent = getPendingIntent(sms.getDateCreated().getTime(), SmsDeliveredReceiver.class);

    SmsManager smsManager = getSmsManager(sms.getSubscriptionId());
    ArrayList<String> smsMessage = smsManager.divideMessage(sms.getMessage());
    for (int i = 0; i < smsMessage.size(); i++) {
        sentPendingIntents.add(i, sentPendingIntent);
        if (deliveryReports) {
            deliveredPendingIntents.add(i, deliveredPendingIntent);
        }
    }
    smsManager.sendMultipartTextMessage(
        sms.getRecipientPhoneNumber(),
        null,
        smsMessage,
        sentPendingIntents,
        deliveryReports ? deliveredPendingIntents : null
    );
}
 
Example 4
Source File: Utils.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
/**
 * 发送短信息
 *
 * @param phoneNumber 接收号码
 * @param content     短信内容
 */
private void toSendSMS(Context context, String phoneNumber, String content) {
    if (context == null) {
        throw new IllegalArgumentException("context can not be null.");
    }
    PendingIntent sentIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
    SmsManager smsManager = SmsManager.getDefault();

    if (content.length() >= 70) {
        //短信字数大于70,自动分条
        List<String> ms = smsManager.divideMessage(content);
        for (String str : ms) {
            //短信发送
            smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
        }
    } else {
        smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
    }
}
 
Example 5
Source File: sendSMS.java    From ShellMS with GNU General Public License v3.0 6 votes vote down vote up
private void sendsms(final String phoneNumber, final String message, final Boolean AddtoSent)	{
try {
	String SENT = TAG + "_SMS_SENT";
	Intent myIntent = new Intent(SENT);
   	PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, myIntent, 0);
       
   	SmsManager sms = SmsManager.getDefault();
       ArrayList<String> msgparts = sms.divideMessage(message);
   	ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
   	int msgcount = msgparts.size();

   	for (int i = 0; i < msgcount; i++) {
           sentPendingIntents.add(sentPI);
       }

   	sms.sendMultipartTextMessage(phoneNumber, null, msgparts, sentPendingIntents, null);
       if (AddtoSent)	{
		addMessageToSent(phoneNumber, message);
	}
} catch (Exception e) {
       e.printStackTrace();
       Log.e(TAG, "undefined Error: SMS sending failed ... please REPORT to ISSUE Tracker");
   }
  }
 
Example 6
Source File: SMS.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static boolean sendSMS(String destination, String message) {
    try {

        // TODO TRACK PARTS ON SEND INTENTS
        final SmsManager smsManager = SmsManager.getDefault();
        if (message.length() > 160) {
            final ArrayList<String> messageParts = smsManager.divideMessage(message);
            smsManager.sendMultipartTextMessage(destination, null, messageParts, null, null);
        } else {
            smsManager.sendTextMessage(destination, null, message, null, null);
        }
        return true;
    } catch (SecurityException e) {
        UserError.Log.wtf(TAG, "Error sending SMS! no permission? " + e);
        // warn user? disable feature?
    }
    return false;
}
 
Example 7
Source File: SmsSenderService.java    From SmsScheduler with GNU General Public License v2.0 6 votes vote down vote up
private void sendSms(SmsModel sms) {
    ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
    ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();
    PendingIntent sentPendingIntent = getPendingIntent(sms.getTimestampCreated(), SmsSentReceiver.class);
    PendingIntent deliveredPendingIntent = getPendingIntent(sms.getTimestampCreated(), SmsDeliveredReceiver.class);

    SmsManager smsManager = getSmsManager(sms.getSubscriptionId());
    ArrayList<String> smsMessage = smsManager.divideMessage(sms.getMessage());
    boolean deliveryReports = PreferenceManager
        .getDefaultSharedPreferences(getApplicationContext())
        .getBoolean(SmsSchedulerPreferenceActivity.PREFERENCE_DELIVERY_REPORTS, false)
    ;
    for (int i = 0; i < smsMessage.size(); i++) {
        sentPendingIntents.add(i, sentPendingIntent);
        if (deliveryReports) {
            deliveredPendingIntents.add(i, deliveredPendingIntent);
        }
    }
    smsManager.sendMultipartTextMessage(
        sms.getRecipientNumber(),
        null,
        smsMessage,
        sentPendingIntents,
        deliveryReports ? deliveredPendingIntents : null
    );
}
 
Example 8
Source File: Tracking.java    From Finder with GNU General Public License v3.0 5 votes vote down vote up
private void append_send_coordinates(String lat, String lon, String speed, String date) {
    //creating message
    sms_text.append(lat);
    sms_text.append(";");
    sms_text.append(lon);
    sms_text.append(";");
    sms_text.append(speed);
    sms_text.append(";");
    sms_text.append(date);
    sms_text.append("\n");
    coords_counter++;

    //buffer is full, time to send or stop service
    if (coords_counter == sms_buffer_max) {
        coords_counter = 0;
        if (sms_counter < sms_number) {
            if ((Build.VERSION.SDK_INT >= 23 &&
                    (getApplicationContext().checkSelfPermission(Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED)) ||
                    Build.VERSION.SDK_INT < 23) {
                SmsManager sManager = SmsManager.getDefault();
                ArrayList<String> parts = sManager.divideMessage(sms_text.toString());
                sManager.sendMultipartTextMessage(phone, null, parts, null,null);
                sms_text = new StringBuilder("");
                sms_counter++;
                builder.setContentText(getString(R.string.sms_sent, sms_counter));

                //update fields in TrackingStatus via intent
                update_intent.setAction("update_fields");
                LocalBroadcastManager.getInstance(this).sendBroadcast(update_intent);
            }
        }

        //second check to stop service straight after sending all messages
        if (sms_counter == sms_number) {
            //all SMS are sent, notification will be created in onDestroy
            stopSelf();
        }
    }
}
 
Example 9
Source File: SmsReceiver.java    From zone-sdk with MIT License 5 votes vote down vote up
/**
 * Call requires API level 4
 * <uses-permission android:name="android.permission.SEND_SMS"/>
 *
 * @param phone
 * @param msg
 */
public static void sendMsgToPhone(String phone, String msg) {
    LogZSDK.INSTANCE.i( "发送手机:" + phone + " ,内容: " + msg);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) {
        SmsManager manager = SmsManager.getDefault();
        List<String> texts = manager.divideMessage(msg);
        for (String txt : texts) {
            manager.sendTextMessage(phone, null, txt, null, null);
        }
    }else{
        LogZSDK.INSTANCE.e( "发送失败,系统版本低于DONUT," + phone + " ,内容: " + msg);
    }

}
 
Example 10
Source File: SmsSenderService.java    From Locate-driver with GNU General Public License v3.0 5 votes vote down vote up
public void sendSMS(String phoneNumber, String message) {
    //Log.d(TAG, "Send SMS: " + phoneNumber + ", " + message);
    //on samsung intents can't be null. the messages are not sent if intents are null
    ArrayList<PendingIntent> samsungFix = new ArrayList<>();
    samsungFix.add(PendingIntent.getBroadcast(context, 0, new Intent("SMS_RECEIVED"), 0));

    SmsManager smsManager = SmsManager.getDefault();
    ArrayList<String> parts = smsManager.divideMessage(message);
    smsManager.sendMultipartTextMessage(phoneNumber, null, parts, samsungFix, samsungFix);
}
 
Example 11
Source File: SmsReceiver.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
/**
 * Call requires API level 4
 * <uses-permission android:name="android.permission.SEND_SMS"/>
 *
 * @param phone
 * @param msg
 */
public static void sendMsgToPhone(String phone, String msg) {
    LogUtils.i("发送手机:" + phone + " ,内容: " + msg);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) {
        SmsManager manager = SmsManager.getDefault();
        List<String> texts = manager.divideMessage(msg);
        for (String txt : texts) {
            manager.sendTextMessage(phone, null, txt, null, null);
        }
    }else{
        LogUtils.e("发送失败,系统版本低于DONUT," + phone + " ,内容: " + msg);
    }

}
 
Example 12
Source File: SmsReceiver.java    From android-common with Apache License 2.0 5 votes vote down vote up
/**
 * Call requires API level 4
 * <uses-permission android:name="android.permission.SEND_SMS"/>
 *
 * @param phone
 * @param msg
 */
public static void sendMsgToPhone(String phone, String msg) {
    Log.i(TAG, "发送手机:" + phone + " ,内容: " + msg);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) {
        SmsManager manager = SmsManager.getDefault();
        List<String> texts = manager.divideMessage(msg);
        for (String txt : texts) {
            manager.sendTextMessage(phone, null, txt, null, null);
        }
    }else{
        Log.e(TAG, "发送失败,系统版本低于DONUT," + phone + " ,内容: " + msg);
    }

}
 
Example 13
Source File: MainActivity.java    From OpenCircle with GNU General Public License v3.0 5 votes vote down vote up
public void sendSMSNewContact(String name, String phone, String messageString)
{
    Log.d("sendSMSNewContact", messageString);
    if (!TextUtils.isEmpty(phone)) {

        SmsManager smsManager = SmsManager.getDefault();

        isRegisterReceiver = true;

        String action = Constants.ACTION_SENT_SMS_CONTACT + "-" + name;
        PendingIntent sentPendingIntent = PendingIntent
                .getBroadcast(this, 0, new Intent(action), 0);

        registerReceiver(broadcastReceiverSentSMS, new IntentFilter(action));

        ArrayList<String> splitMessage = smsManager.divideMessage(messageString);

        for (int p = 0; p < splitMessage.size(); p++) {
            if (p == 0) {
                smsManager.sendTextMessage(phone, null, splitMessage.get(p), sentPendingIntent,
                        null);
            } else {
                smsManager.sendTextMessage(phone, null, splitMessage.get(p), null, null);
            }
        }
    }

}
 
Example 14
Source File: MainActivity.java    From GPS2SMS with GNU General Public License v3.0 5 votes vote down vote up
public void sendSMS_Debug(String lMsg) {

        phoneToSendSMS = plainPh.getText().toString().replace("-", "")
                .replace(" ", "").replace("(", "").replace(")", "").replace(".", "");

        if (phoneToSendSMS.equalsIgnoreCase("")) {
            DBHelper.ShowToast(MainActivity.this,
                    R.string.error_no_phone_number, Toast.LENGTH_LONG);
        } else {
            try {


            // update saved number
            dbHelper = new DBHelper(MainActivity.this);
            dbHelper.setSlot(0, "", phoneToSendSMS);
            dbHelper.close();

            SmsManager smsManager = SmsManager.getDefault();
            ArrayList<String> parts = smsManager.divideMessage(lMsg);
            smsManager.sendMultipartTextMessage(phoneToSendSMS, null, parts, null, null);

            DBHelper.ShowToastT(MainActivity.this, getString(R.string.info_sms_sent),
                    Toast.LENGTH_SHORT);

            } catch (Exception e) {
                DBHelper.ShowToastT(MainActivity.this, e.getMessage(),
                        Toast.LENGTH_LONG);
            }

        }

    }
 
Example 15
Source File: MainActivity.java    From Msgs with MIT License 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
private void sendSms(final int which,String phone,String context) {
    SubscriptionInfo sInfo = null;

    final SubscriptionManager sManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);

    List<SubscriptionInfo> list = sManager.getActiveSubscriptionInfoList();

    if (list.size() == 2) {
        // 双卡
        sInfo = list.get(which);
    } else {
        // 单卡
        sInfo = list.get(0);
    }

    if (sInfo != null) {
        int subId = sInfo.getSubscriptionId();
        SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(subId);

        if (!TextUtils.isEmpty(phone)) {
            ArrayList<String> messageList =manager.divideMessage(context);
            for(String text:messageList){
                manager.sendTextMessage(phone, null, text, null, null);
            }
            Toast.makeText(this, "信息正在发送,请稍候", Toast.LENGTH_SHORT)
                    .show();
        } else {
            Toast.makeText(this, "无法正确的获取SIM卡信息,请稍候重试",
                    Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 16
Source File: PhoneUtils.java    From Android-UtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * 发送短信
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SEND_SMS"/>}</p>
 *
 * @param phoneNumber 接收号码
 * @param content     短信内容
 */
public static void sendSmsSilent(String phoneNumber, String content) {
    if (StringUtils.isEmpty(content)) return;
    PendingIntent sentIntent = PendingIntent.getBroadcast(Utils.getContext(), 0, new Intent(), 0);
    SmsManager smsManager = SmsManager.getDefault();
    if (content.length() >= 70) {
        List<String> ms = smsManager.divideMessage(content);
        for (String str : ms) {
            smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
        }
    } else {
        smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
    }
}
 
Example 17
Source File: Sms.java    From cordova-sms-plugin with MIT License 4 votes vote down vote up
private void send(final CallbackContext callbackContext, String phoneNumber, String message) {
	SmsManager manager = SmsManager.getDefault();
	final ArrayList<String> parts = manager.divideMessage(message);

	// by creating this broadcast receiver we can check whether or not the SMS was sent
	final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {

		boolean anyError = false; //use to detect if one of the parts failed
		int partsCount = parts.size(); //number of parts to send

		@Override
		public void onReceive(Context context, Intent intent) {
			switch (getResultCode()) {
			case SmsManager.STATUS_ON_ICC_SENT:
			case Activity.RESULT_OK:
				break;
			case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
			case SmsManager.RESULT_ERROR_NO_SERVICE:
			case SmsManager.RESULT_ERROR_NULL_PDU:
			case SmsManager.RESULT_ERROR_RADIO_OFF:
				anyError = true;
				break;
			}
			// trigger the callback only when all the parts have been sent
			partsCount--;
			if (partsCount == 0) {
				if (anyError) {
					callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
				} else {
					callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
				}
				cordova.getActivity().unregisterReceiver(this);
			}
		}
	};

	// randomize the intent filter action to avoid using the same receiver
	String intentFilterAction = INTENT_FILTER_SMS_SENT + java.util.UUID.randomUUID().toString();
	this.cordova.getActivity().registerReceiver(broadcastReceiver, new IntentFilter(intentFilterAction));

	PendingIntent sentIntent = PendingIntent.getBroadcast(this.cordova.getActivity(), 0, new Intent(intentFilterAction), 0);

	// depending on the number of parts we send a text message or multi parts
	if (parts.size() > 1) {
		ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
		for (int i = 0; i < parts.size(); i++) {
			sentIntents.add(sentIntent);
		}
		manager.sendMultipartTextMessage(phoneNumber, null, parts, sentIntents, null);
	}
	else {
		manager.sendTextMessage(phoneNumber, null, message, sentIntent, null);
	}
}
 
Example 18
Source File: SmsIntentService.java    From android-sms-gateway with Apache License 2.0 4 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent)
{
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty())
    {
        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType))
        {
            String number = extras.getString("number");
            String message = extras.getString("message");
            if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(message))
            {
                try
                {
                    if (!number.startsWith("+"))
                    {
                        number = "+" + number;
                    }
                    SmsManager smsManager = SmsManager.getDefault();
                    ArrayList<String> parts = smsManager.divideMessage(message);
                    if (parts.size() > 1)
                    {
                        smsManager.sendMultipartTextMessage(number, null, parts, null, null);
                    }
                    else
                    {
                        smsManager.sendTextMessage(number, null, message, null, null);
                    }

                    String result = number + ": " + message;
                    Log.i(TAG, result);

                    sendNotification(result);

                    ContentValues values = new ContentValues();
                    values.put("address", number);
                    values.put("body", message);
                    getApplicationContext().getContentResolver()
                                           .insert(Uri.parse("content://sms/sent"), values);
                }
                catch (Exception ex)
                {
                    Log.e(TAG, ex.toString());
                }
            }
        }
    }
    SmsBroadcastReceiver.completeWakefulIntent(intent);
}
 
Example 19
Source File: MainActivity.java    From OpenCircle with GNU General Public License v3.0 4 votes vote down vote up
public void sendSMSWithBody(String messageString)
{

    Log.d(LOG_TAG, messageString);

    showAlertSentMessageSuccess = false;
    numMessagesSent = 0;
    numSmsSent = 0;

    SmsManager sm = SmsManager.getDefault();

    Set<String> sentNumbers = new HashSet<>();

    for(int i = 0; i < contacts.size(); i++)
    {

        String uniqueNumber = contacts.get(i).getPhoneNumber();

        if(! sentNumbers.contains(uniqueNumber))
        {
            sentNumbers.add(uniqueNumber);
        }
        else
        {
            continue;
        }

        uniqueNumber = cleanNumber(uniqueNumber);

        if(! TextUtils.isEmpty(uniqueNumber))
        {

            numSmsSent++;
            isRegisterReceiver = true;

            String action = Constants.ACTION_SENT_SMS + "-" + contacts.get(i)
                                                                      .getPhoneNumber() + "-" + contacts
                    .get(i).getName();

            PendingIntent sentPendingIntent = PendingIntent
                    .getBroadcast(this, 0, new Intent(action), 0);

            registerReceiver(broadcastReceiverSentSMS, new IntentFilter(action));

            ArrayList<String> splitMessage = sm.divideMessage(messageString);

            for(int p = 0; p < splitMessage.size(); p++)
            {

                if(p == 0)
                {
                    sm.sendTextMessage(uniqueNumber, null, splitMessage.get(p),
                                       sentPendingIntent, null);
                }
                else
                {
                    sm.sendTextMessage(uniqueNumber, null, splitMessage.get(p), null, null);
                }
            }

        }
    }
}
 
Example 20
Source File: CallAndSmsPresenter.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    //注册广播接收者
    unRegisterReceiver();
    mCallReceiver = new CallAndSmsReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL);
    intentFilter.addAction(SMS_SEND_ACTION);
    mContext.registerReceiver(mCallReceiver, intentFilter);

    // EventBus.getDefault().post(new RecordUpdateEvent(RecordUpdateEvent.RECORD_IDLE));
    switch (type) {
        case 0:     //电话
            Intent speechIntent = new Intent(mContext, AssistantService.class);
            speechIntent.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.STOP_VOICE_MODE);
            mContext.startService(speechIntent);
            Log.i("LingJu", "手机厂商:" + Build.MANUFACTURER);
            //由于华为、小米、三星手机无法直接呼出紧急电话,所以在该号码前加区号(魅族可以)
            if (number.length() == 3 && number.matches("^(110|119|120)$") && !"Meizu".equals(Build.MANUFACTURER)) {
                String city = Setting.formatCity(Setting.getAddress().getCity());
                number = CallAndSmsDao.getInstance(mContext).getZipCode(city) + number;
            }
            // PermissionUtils.checkPermission(mContext, PermissionUtils.OP_CALL_PHONE);
            Intent icall = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + this.number));
            icall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            mContext.startActivity(icall);

            break;
        case 1:     //短信
            // PermissionUtils.checkPermission(mContext, PermissionUtils.OP_SEND_SMS);
            SmsManager smsManager = SmsManager.getDefault();
            if (content != null && content.length() > 0) {
                content += "-发自小灵机器人";
                //切分短信,每七十个汉字为一条短信,不足七十就只有一条:返回的是字符串的List集合
                List<String> texts = smsManager.divideMessage(content);
                //发送短信
                PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, new Intent(SMS_SEND_ACTION), 0);
                for (String tt : texts) {
                    phoneNumber = number;
                    smsContent = tt;
                    smsManager.sendTextMessage(number, null, tt, pi, null);
                }
            }
            break;
    }
    /* 停止识别、合成 */
    Intent intent = new Intent(mContext, AssistantService.class);
    intent.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.SEND_TO_ROBOT_FOR_END_TASK);
    intent.putExtra(AssistantService.TRY_TO_WAKEUP, false);
    mContext.startService(intent);
    if (EventBus.getDefault().hasSubscriberForEvent(CallTaskEvent.class)) {
        EventBus.getDefault().post(new CallTaskEvent(CallTaskEvent.STATE_END));
    }

    cancelCommunicationTimer();
}