How to send sms message inside broadcast receiver class?

Does your AndroidManifest. Xml include the SEND_SMS permission? EDIT: try this and see if it prints anything out: Override public void onReceive(Context context, Intent intent) { Intent I = new Intent(context, smsReceiver.

Class); PendingIntent pi = PendingIntent. GetBroadcast(context, 0, i, 0); Bundle bundle = intent.getExtras(); String str = ""; String phonenumber = ""; String houseNumber ="22"; String message = "Two bedrooms Two Baths"; try{ SmsMessage msgs = null; SmsManager sms = SmsManager.getDefault(); if(bundle! = null){ Objectpdus = (Object)bundle.

Get("pdus"); msgs = new SmsMessagepdus. Length; for(int i2=0; i2CreateFromPdu((byte)pdusi2); phonenumber += msgsi2. GetOriginatingAddress(); str += msgsi2.getMessageBody().toString(); } sms.

SendTextMessage(phonenumber, null, message, pi, null); } }catch(Exception e1){ android.util.Log. V("SMS ERROR","Exception sending SMS "+e1.getMessage()+"", e1); } }.

Does your AndroidManifest. Xml include the SEND_SMS permission? EDIT: try this and see if it prints anything out: @Override public void onReceive(Context context, Intent intent) { Intent I = new Intent(context, smsReceiver.

Class); PendingIntent pi = PendingIntent. GetBroadcast(context, 0, i, 0); Bundle bundle = intent.getExtras(); String str = ""; String phonenumber = ""; String houseNumber ="22"; String message = "Two bedrooms Two Baths"; try{ SmsMessage msgs = null; SmsManager sms = SmsManager.getDefault(); if(bundle! = null){ Objectpdus = (Object)bundle.

Get("pdus"); msgs = new SmsMessagepdus. Length; for(int i2=0; i2CreateFromPdu((byte)pdusi2); phonenumber += msgsi2. GetOriginatingAddress(); str += msgsi2.getMessageBody().toString(); } sms.

SendTextMessage(phonenumber, null, message, pi, null); } }catch(Exception e1){ android.util.Log. V("SMS ERROR","Exception sending SMS "+e1.getMessage()+"", e1); } }.

Femi Yes is does send and receive....Everytime I run the program it force closes after I receive a message. – theITRanger22 Jun 26 at 15:37 1 If it force closes then you must have an error in the android logs: add your error log output to your question. – Femi Jun 26 at 15:40 06-26 15:49:57.357: ERROR/ContactsProvider(175): at android.os.Binder.

ExecTransact(Binder. Java:320) – theITRanger22 Jun 26 at 15:52 @Femi I just posted my errors in question. Thanks dude – theITRanger22 Jun 26 at 15:55 Ah, well, the code you have posted is not accessing the ContactsProvider at all so it is a little odd that a failure in the ContactsProvider will cause a force close in your application.

Are you doing anything in MainActivity with the ContactsProvider? – Femi Jun 26 at 16:04.

Sms message inside broadcast receiver class is sent (without quotes):. Send sms message inside broadcast receiver class.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions