android - i want to make my sms notification stay till there is a button to remove the notification -
public class incomingsms extends broadcastreceiver {
// object of smsmanager final smsmanager sms = smsmanager.getdefault(); public void onreceive(context context, intent intent) { // retrieves map of extended data intent. final bundle bundle = intent.getextras(); try { if (bundle != null) { final object[] pdusobj = (object[]) bundle.get("pdus"); (int = 0; < pdusobj.length; i++) { smsmessage currentmessage = smsmessage.createfrompdu((byte[]) pdusobj[i]); string phonenumber = currentmessage.getdisplayoriginatingaddress(); string sendernum = phonenumber; string message = currentmessage.getdisplaymessagebody(); log.i("smsreceiver", "sendernum: "+ sendernum + "; message: " + message); // show alert int duration = toast.length_long; toast toast = toast.maketext(context, "sendernum: "+ sendernum + ", message: " + message, duration); toast.show(); } // end loop } // bundle null } catch (exception e) { log.e("smsreceiver", "exception smsreceiver" +e); } } }
i want make notification stop till have pressed button.here notification coming short ....how can make stay till press abutton...please me
instead of showing toast message, use such alertdialog, or other dialog of choice interact user.
remember lifecycle when device swaps rotation (and destroy/recreate dialog), , go.
Comments
Post a Comment