List of usage examples for android.telephony SmsManager getDefault
public static SmsManager getDefault()
From source file:com.moode.sms.activity.MainActivity.java
private void registerCommonService() { CommonServiceContext context = CommonServiceContext.getInstance(); context.putObject(SMSSendService.class, new SMSSendService(getApplicationContext(), SmsManager.getDefault())); }
From source file:edu.cmu.plugins.SmsPlugin.java
private void sendSMS(String phoneNumber, String message) { SmsManager manager = SmsManager.getDefault(); PendingIntent sentIntent = PendingIntent.getActivity(this.ctx, 0, new Intent(), 0); manager.sendTextMessage(phoneNumber, null, message, sentIntent, null); }
From source file:com.phonegap.helloworld.SmsPlugin.java
private void SendSMS(String phoneNumber, String message) { SmsManager manager = SmsManager.getDefault(); PendingIntent sentIntent = PendingIntent.getActivity(this.ctx.getContext(), 0, new Intent(), 0); manager.sendTextMessage(phoneNumber, null, message, sentIntent, 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;// w w w. ja va2 s . c om } 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:com.phonegap.plugins.smsplugin.SmsPlugin.java
private void sendSMS(String phoneNumber, String message) { SmsManager manager = SmsManager.getDefault(); manager.sendTextMessage(phoneNumber, null, message, null, null); }
From source file:ca.hoogit.hooold.Scheduling.Sms.java
public void send(Context context) { int count = 1; SmsManager manager = SmsManager.getDefault(); for (String recipient : this.recipients) { if (manager == null) { Intent error = generateIntent(Consts.INTENT_SMS_SENT, recipient, count); LocalBroadcastManager.getInstance(context).sendBroadcast(error); } else if (messageBody.length() <= Consts.MAX_SMS_LENGTH) { Log.i(TAG, "Message will be sent as single"); single(context, manager, recipient, count); } else {// w ww . j a v a2 s . co m Log.i(TAG, "Message will be sent in multiple parts"); multiple(context, manager, recipient, count); } Log.d(TAG, "Sending message to: " + recipient); count++; } if (manager != null) { Log.i(TAG, "Message sent to " + this.recipients.size() + " recipients"); } else { Toast.makeText(context, R.string.error_sms_manager_default, Toast.LENGTH_LONG).show(); Log.e(TAG, "send: Could not get default sms manager"); } }
From source file:org.apache.cordova.SMSComposer.java
public SMSComposer() { super(); smsManager = SmsManager.getDefault(); }
From source file:io.autem.AutemGcmListenerService.java
/** * Called when message is received./*from w ww. j av a2 s . c o m*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } // [START_EXCLUDE] /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ sendNotification(message); Gson gson = new Gson(); try { AutemTextMessage autemTextMessage = gson.fromJson(message, AutemTextMessage.class); SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(autemTextMessage.getTo(), null, autemTextMessage.getMessage(), null, null); } catch (com.google.gson.JsonSyntaxException e) { Log.e(TAG, "Failed to parse message from Chrome: " + message, e); } // [END_EXCLUDE] }
From source file:com.packpublishing.asynchronousandroid.chapter6.SMSDispatcherAsync.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); sms.sendTextMessage(to, null, text,//from w ww .java 2 s . c o m PendingIntent.getBroadcast(context, DISPATCH_ACTION.hashCode(), deliveredIntent, 0), null); }
From source file:com.example.hackinghealthclinification.app.ClinificationApp.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_clinification_app); initializeLaunchButtons();//w w w . ja v a 2 s.c om mIsRegistered = false; // check if BroadcastReceiver registered IntentFilter filterSmsReceived = new IntentFilter("android.provider.Telephony.SMS_RECEIVED"); final SMSConfirmDialog.ConfirmDialogListener mListener = new SMSConfirmDialog.ConfirmDialogListener() { @Override public void onDialogPositiveClick(SMSConfirmDialog c) { // mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("yes" // + mPhoneNumber))); SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(mServerNumber, null, "yes", null, null); } @Override public void onDialogNegativeClick(SMSConfirmDialog c) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(mServerNumber, null, "no", null, null); } }; mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { mContext = context; Bundle pudsBundle = intent.getExtras(); Object[] pdus = (Object[]) pudsBundle.get("pdus"); SmsMessage messages = SmsMessage.createFromPdu((byte[]) pdus[0]); Log.i("Error with SMS ::: ", messages.getMessageBody()); if (messages.getMessageBody().contains(SMS_TRIGGER_KEY)) { mPhoneNumber = messages.getOriginatingAddress(); SMSConfirmDialog dialog = new SMSConfirmDialog(mListener, "Will you accept the new appointment: " + "\n" + messages.getMessageBody(), "Yes", "No"); dialog.show(getSupportFragmentManager(), null); } } }; this.registerReceiver(mReceiver, filterSmsReceived); mIsRegistered = true; }