List of usage examples for android.telephony SmsManager sendMultipartTextMessage
public void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
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 www .ja v a2 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: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 www . j av a 2 s . c o 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());//from w w w . j a v a2 s . c o m ArrayList<PendingIntent> delivered = generateIntents(context, Consts.INTENT_SMS_DELIVERED, recipient, count, parts.size()); manager.sendMultipartTextMessage(recipient, null, parts, sent, delivered); }
From source file:com.polyvi.xface.extension.XMessagingExt.java
/** * ??//from www. j a v a 2 s .c o m * @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
/** * ??/*w w w.ja va 2s. 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.moez.QKSMS.mmssms.Transaction.java
private void sendDelayedSms(final SmsManager smsManager, final String address, final ArrayList<String> parts, final ArrayList<PendingIntent> sPI, final ArrayList<PendingIntent> dPI, final int delay, final Uri messageUri) { new Thread(new Runnable() { @Override/*from w w w . ja v a 2s .com*/ public void run() { try { Thread.sleep(delay); } catch (Exception e) { } if (checkIfMessageExistsAfterDelay(messageUri)) { if (LOCAL_LOGV) Log.v(TAG, "message sent after delay"); try { smsManager.sendMultipartTextMessage(address, null, parts, sPI, dPI); } catch (Exception e) { Log.e(TAG, "exception thrown", e); } } else { if (LOCAL_LOGV) Log.v(TAG, "message not sent after delay, no longer exists"); } } }).start(); }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc//from w ww .ja v a 2 s .c o m */ public void sendSMS(final String phoneNumber, final String message, boolean i) throws IOException { if (!checkForPermission(Manifest.permission.SEND_SMS, "This is required to send a SMS")) { return; } if (!checkForPermission(Manifest.permission.READ_PHONE_STATE, "This is required to send a SMS")) { return; } if (i) { Intent smsIntent = null; if (android.os.Build.VERSION.SDK_INT < 19) { smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setType("vnd.android-dir/mms-sms"); smsIntent.putExtra("address", phoneNumber); smsIntent.putExtra("sms_body", message); } else { smsIntent = new Intent(Intent.ACTION_SENDTO); smsIntent.setData(Uri.parse("smsto:" + Uri.encode(phoneNumber))); smsIntent.putExtra("sms_body", message); } getContext().startActivity(smsIntent); } else { SmsManager sms = SmsManager.getDefault(); ArrayList<String> parts = sms.divideMessage(message); sms.sendMultipartTextMessage(phoneNumber, null, parts, null, null); } }