@Override public void onReceive(Context context, Intent intent) { if (!intent.getAction().equals("org.rapidandroid.intents.SMS_FORWARD")) { throw new RuntimeException(); } SmsManager smgr = SmsManager.getDefault(); Bundle extras = intent.getExtras(); if (extras != null) { Log.d(this.getClass().getName(), "SMS forwarding in progress"); String mesg = extras.getString("msg"); String[] fwdnums = extras.getStringArray("forwardNums"); for (String destinationAddr : fwdnums) { // String destinationAddr = extras.getString(KEY_DESTINATION_PHONE); // String mesg = extras.getString(KEY_MESSAGE); smgr.sendTextMessage(destinationAddr, null, mesg, null, null); } Log.d(this.getClass().getName(), "SMS forwarding complete"); } }
@Override public void onCreate() { HandlerThread thread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); mSmsManager = SmsManager.getDefault(); }
/** * Creates a new TextMessage component. * * @param container ignored (because this is a non-visible component) */ public Textingsvc(SvcComponentContainer container) { super(container.$formService()); IntentFilter intentFilter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED"); container.$context().registerReceiver(receiver, intentFilter); Log.d("Simple", "Texting constructor"); smsManager = SmsManager.getDefault(); PhoneNumber(""); receivingEnabled = true; formService.registerForOnStartCommand(this); formService.registerForOnDestroy(this); }
@Override public void onReceive(Context context, Intent intent) { SmsManager smgr = SmsManager.getDefault(); Bundle extras = intent.getExtras(); if (extras != null) { if (extras.containsKey(KEY_DESTINATION_PHONE) && extras.containsKey(KEY_MESSAGE)) { String destinationAddr = extras.getString(KEY_DESTINATION_PHONE); String mesg = extras.getString(KEY_MESSAGE); /** TODO if mesg.length > 160(i think?) chars then this throws exception. would need * to use the version that sends segmented sms **/ smgr.sendTextMessage(destinationAddr, null, mesg, null, null); } } }
public static void sendSMS(String destSMS, String message) { SmsManager sm = SmsManager.getDefault(); sm.sendTextMessage(destSMS, null, message, null, null); }
public void sayHello(View v) { String _messageNumber="+447933037883"; String messageText = ""; SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(_messageNumber, null, messageText, null, null); }