android - How to put the received sms in a string attribute -
i wrote program displayed receiving sms. trouble putting sms string variable.
object[] pdus = (object[]) bundle.get("pdus"); msgs = new smsmessage[pdus.length]; (int i=0; i<msgs.length; i++){ msgs[i] = smsmessage.createfrompdu((byte[])pdus[i]); str += "sms " + msgs[i].getoriginatingaddress(); str += " :"; str += msgs[i].getmessagebody().tostring(); str += "\n"; } //---display new sms message--- toast.maketext(context, str, toast.length_short).show(); intent intenthome = new intent(context,mainactivity.class); intenthome.setflags(intent.flag_activity_new_task); context.startactivity(intenthome);
how can put entire message 1 string variable have tried this,,,
string s = new string(str) ;
didn't work. also, want use string settext viewtext variable
i used code, worked when called message mainactivity class. but, indeed, want use in same class
public class smsreceiver extends broadcastreceiver
i wrote
set_sms(); //---display new sms message--- intent intenthome = new intent(context,mainactivity.class); intenthome.putextra("msgcontent", message); intenthome.setflags(intent.flag_activity_new_task); context.startactivity(intenthome); } void set_sms() { activity x = new activity() ; bundle extras = x.getintent().getextras(); if (extras != null) { message = extras.getstring("msgcontent"); } }
but, there error
Comments
Post a Comment