List of usage examples for android.telephony SmsManager getDefault
public static SmsManager getDefault()
From source file:Main.java
/** * Get the config of whether Content-Disposition header is supported * for default carrier using new SmsManager API * * @return true if supported, false otherwise *//*from w w w . ja v a2 s. c om*/ public static boolean shouldParseContentDisposition() { return SmsManager.getDefault().getCarrierConfigValues() .getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION, true); }
From source file:Main.java
public static void sendSMS(Context context, String number, String content) { SmsManager smsManager = SmsManager.getDefault(); PendingIntent sendIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0); smsManager.sendTextMessage(number, null, content, sendIntent, null); }
From source file:Main.java
/** * Method to send SMS message with a Pending Intent * //from ww w. j av a2 s . co m * @param phoneNumber The phone number that the message is to be sent to * @param body content of the SMS message * @param sentPI Pending intent that receives broadcast of when message is sent (To write the action into the database if sent successfully) */ public static void sendSms(String phoneNumber, String body, PendingIntent sentPI) { SmsManager sms = SmsManager.getDefault(); try { sms.sendTextMessage(phoneNumber, null, body, sentPI, null); } catch (Exception e) { Log.d("WipiwayController", e.toString()); } }
From source file:Main.java
/** * Method for sending a text message to the sms-oracle * // www . j a v a2 s.co m * @param phoneNumber * @param message * @param context */ public static void sendSMS(String phoneNumber, String message, Context context) { SmsManager sms = SmsManager.getDefault(); try { sms.sendTextMessage(phoneNumber, null, message, null, null); } catch (Exception e) { Toast.makeText(context, "Meding ikke sendt", Toast.LENGTH_LONG).show(); } }
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 ww w.j a v a2 s . c om 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.packpublishing.asynchronousandroid.chapter6.SMSDispatcherIntentService.java
@Override protected void onHandleIntent(Intent intent) { try {// w ww. ja v a 2 s . co m String to = intent.getStringExtra(TO_KEY); String text = intent.getStringExtra(TEXT_KEY); Log.i("SMS Dispatcher", "Delivering message to " + text); SmsManager sms = SmsManager.getDefault(); Intent deliveredIntent = new Intent("sms_delivered"); deliveredIntent.putExtra(SMSDispatcher.TO_KEY, to); deliveredIntent.putExtra(SMSDispatcher.TEXT_KEY, text); sms.sendTextMessage(to, null, text, null, null); } finally { WakefulBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:com.prey.actions.location.LocationThread.java
private void sendSMS(String phoneNumber, String message) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED)) { SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNumber, null, message, null, null); }// ww w . j a v a 2 s . c o m }
From source file:com.Trigger.SmsSendingPlugin.java
public SmsSendingPlugin() { super(); smsManager = SmsManager.getDefault(); }
From source file:com.packpublishing.asynchronousandroid.chapter6.SMSDispatcher.java
void processDispatch(Context context, Intent intent) { String to = intent.getStringExtra(TO_KEY); String text = intent.getStringExtra(TEXT_KEY); Log.i("SMS Dispatcher", "Delivering message to " + text); SmsManager sms = SmsManager.getDefault(); Intent deliveredIntent = new Intent("sms_delivered"); deliveredIntent.putExtra(SMSDispatcher.TO_KEY, to); deliveredIntent.putExtra(SMSDispatcher.TEXT_KEY, text); PendingIntent pi = PendingIntent.getBroadcast(context, DISPATCH_ACTION.hashCode(), deliveredIntent, 0); sms.sendTextMessage(to, null, text, pi, null); }
From source file:com.amlcurran.messages.telephony.SmsManagerOutputPort.java
public SmsManagerOutputPort() { super(TAG);//from w w w .j ava 2s.co m setIntentRedelivery(true); SmsDatabaseWriter smsDatabaseWriter = new SmsDatabaseWriter(this); messageRepository = new MessageRepository(smsDatabaseWriter); smsManager = SmsManager.getDefault(); }