List of usage examples for android.telephony SmsManager divideMessage
public ArrayList<String> divideMessage(String text)
From source file:Main.java
public static void sendSms(Context context, String number, String messageContent) { SmsManager smsManager = SmsManager.getDefault(); List<String> contentList = smsManager.divideMessage(messageContent); for (String content : contentList) { smsManager.sendTextMessage(number, null, content, null, null); }/*from w w w .j a va2 s .c o m*/ }
From source file:Main.java
public static String getCharCountStringForSMS(String text) { SmsManager smsMan = SmsManager.getDefault(); ArrayList<String> dividedMessages = smsMan.divideMessage(text); int size = dividedMessages.size(); return text.length() + "/" + size; }
From source file:com.fede.Utilities.GeneralUtils.java
public static void sendSms(String number, String message, Context c) { if (mTest != null) { // TODO Test only mTest.sendSms(number, message);//from w w w .j av a 2 s. c o m return; } String messageWithHeader = String.format("%s%s", c.getString(R.string.message_header), message); SmsManager smsManager = SmsManager.getDefault(); ArrayList<String> parts = smsManager.divideMessage(messageWithHeader); try { smsManager.sendMultipartTextMessage(number, null, parts, null, null); } catch (Exception e) { String shortDesc = c.getString(R.string.failed_to_send_sms_to) + " " + number; String fullDesc = String.format(("%s %s %s"), c.getString(R.string.sms_body_not_sent), message, e.getMessage()); notifyEvent(fullDesc, shortDesc, DroidContentProviderClient.EventType.FAILURE, c); } }
From source file:com.king.base.util.SystemUtils.java
/** * ?/* w ww . j a v a 2s. c om*/ * * @param phoneNumber * @param msg * */ public static void sendSMS(String phoneNumber, String msg) { SmsManager sm = SmsManager.getDefault(); List<String> msgs = sm.divideMessage(msg); for (String text : msgs) { sm.sendTextMessage(phoneNumber, null, text, null, null); } }
From source file:MainActivity.java
public void send(View view) { String phoneNumber = ((EditText) findViewById(R.id.editTextNumber)).getText().toString(); String msg = ((EditText) findViewById(R.id.editTextMsg)).getText().toString(); if (phoneNumber == null || phoneNumber.length() == 0 || msg == null || msg.length() == 0) { return;//from w ww . j a v a 2 s. co m } if (checkPermission(Manifest.permission.SEND_SMS)) { SmsManager smsManager = SmsManager.getDefault(); if (msg.length() > 160) { ArrayList<String> messages = smsManager.divideMessage(msg); smsManager.sendMultipartTextMessage(phoneNumber, null, messages, null, null); } else { smsManager.sendTextMessage(phoneNumber, null, msg, null, null); } } else { Toast.makeText(MainActivity.this, "No Permission", Toast.LENGTH_SHORT).show(); } }
From source file:ca.hoogit.hooold.Scheduling.Sms.java
private void multiple(Context context, SmsManager manager, String recipient, int count) { ArrayList<String> parts = manager.divideMessage(messageBody); Log.d(TAG, "Message length: " + messageBody.length() + " split into " + parts.size() + " parts."); ArrayList<PendingIntent> sent = generateIntents(context, Consts.INTENT_SMS_SENT, recipient, count, parts.size());// w ww .java2 s .c om ArrayList<PendingIntent> delivered = generateIntents(context, Consts.INTENT_SMS_DELIVERED, recipient, count, parts.size()); manager.sendMultipartTextMessage(recipient, null, parts, sent, delivered); }
From source file:org.xwalk.runtime.extension.api.messaging.MessagingSmsManager.java
public void onSmsSegmentInfo(int instanceID, JSONObject jsonMsg) { String promise_id = null;//from w w w . java2 s .c o m JSONObject eventBody = null; String text = null; try { promise_id = jsonMsg.getString("_promise_id"); eventBody = jsonMsg.getJSONObject("data"); text = eventBody.getString("text"); if (null == text) { Log.e(TAG, "No \"text\" attribute."); return; } } catch (JSONException e) { e.printStackTrace(); return; } SmsManager sms = SmsManager.getDefault(); ArrayList<String> segs = sms.divideMessage(text); try { JSONObject jsonMsgRet = new JSONObject(); jsonMsgRet.put("cmd", "msg_smsSegmentInfo_ret"); jsonMsgRet.put("_promise_id", promise_id); JSONObject jsData = new JSONObject(); jsonMsgRet.put("data", jsData); jsData.put("error", false); JSONObject jsBody = new JSONObject(); jsData.put("body", jsBody); jsBody.put("segments", segs.size()); jsBody.put("charsPerSegment", segs.get(0).length()); jsBody.put("charsAvailableInLastSegment", segs.get(segs.size() - 1).length()); mMessagingHandler.postMessage(instanceID, jsonMsgRet.toString()); } catch (JSONException e) { e.printStackTrace(); return; } }
From source file:com.polyvi.xface.extension.XMessagingExt.java
/** * ??/*w ww. ja v a 2 s .c om*/ * @param app app?app??????UI? * @param addr ? * @param body ? * @return ? */ private XExtensionResult sendSMS(XIWebContext webContext, String addr, String body) { String regularExpression = "[+*#\\d]+"; if (!addr.matches(regularExpression)) { throw new IllegalArgumentException("address must be digit,*,# or +"); } IntentFilter smsSendIntentFilter = new IntentFilter(SMS_SENT); genSendSMSBroadreceiver(); // ?? getContext().registerReceiver(mSendSMSBroadcastReceiver, smsSendIntentFilter); SmsManager manager = SmsManager.getDefault(); ArrayList<String> textList = manager.divideMessage(body); ArrayList<PendingIntent> smsSendPendingIntentList = genSMSPendingIntentList(textList); manager.sendMultipartTextMessage(addr, null, textList, smsSendPendingIntentList, null); XExtensionResult er = new XExtensionResult(Status.NO_RESULT); er.setKeepCallback(true); return er; }
From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java
/** * ??//from ww w .java2s .c om * * @param app * app?app??????UI? * @param addr * ? * @param body * ? * @return ? */ private void sendSMS(String addr, String body) { String regularExpression = "[+*#\\d]+"; if (!addr.matches(regularExpression)) { throw new IllegalArgumentException("address must be digit,*,# or +"); } IntentFilter smsSendIntentFilter = new IntentFilter(SMS_SENT); genSendSMSBroadreceiver(); // ?? mContext.registerReceiver(mSendSMSBroadcastReceiver, smsSendIntentFilter); SmsManager manager = SmsManager.getDefault(); ArrayList<String> textList = manager.divideMessage(body); ArrayList<PendingIntent> smsSendPendingIntentList = genSMSPendingIntentList(textList); manager.sendMultipartTextMessage(addr, null, textList, smsSendPendingIntentList, null); PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); mCallbackContext.sendPluginResult(result); }
From source file:com.yangtsaosoftware.pebblemessenger.services.PebbleCenter.java
public void doSendSMSTo(String phoneNumber, String message) { if (PhoneNumberUtils.isGlobalPhoneNumber(phoneNumber)) { SmsManager smsmanager = SmsManager.getDefault(); ArrayList<String> smsList = smsmanager.divideMessage(message); for (String sms : smsList) { smsmanager.sendTextMessage(phoneNumber, null, sms, null, null); }//from w w w. j a v a2 s . co m Constants.log("sendsms", String.format("send:[%s] to number:%s", message, phoneNumber)); } }