how use global string in broadcast receiver? wrong sms variable?
public class mainactivity extends activity { string sms=""; //here wrong??? textview view = new textview(this); uri urismsuri = uri.parse("content://sms/inbox"); cursor cur = getcontentresolver().query(urismsuri, null, null, null ,null); while (cur.movetonext()) { if(cur.getstring(13).startswith("\n ")){ sms +=cur.getstring(13)+"\n"; } } textview text = (textview) findviewbyid(r.id.tabel); text.settext(sms); //here works private final broadcastreceiver smsreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { bundle bundle=intent.getextras(); object messages[]=(object[])bundle.get("pdus"); smsmessage smsmessage[]=new smsmessage[messages.length]; (int i=0; < messages.length; i++) { smsmessage[i]=smsmessage.createfrompdu((byte[])messages[i]); } if(smsmessage[0].getmessagebody().startswith("\n ")){ sms +=smsmessage[0].getmessagebody(); //or here wrong? } textview text = (textview) findviewbyid(r.id.tabel); text.settext(sms);
i want make list sms received , list must updated when received sms.
what creating class , put static variables in it.
so example,
class values { static public activity frontactivity = null; static public int currentstatus = status.idle; }
and access them like
values.frontactivity = this; values.currentstatis = status.active;