android - How can I change my notification text? -
i devoleping application android.i have alarmmanager.this alarmmanager cannot stoppable.everytime(every 2 seconds) checking list according random number.random number check database , giving decision notificationmanager.İf list line not green.it make it.my problem when line green.my notification text doesn"t change.how can fix ?
my alarmmanagerreceiver :
databasehelper mdatabasehelper; arraylist listdata = new arraylist<>(); arraylist listdataoran = new arraylist<>(); arraylist listdataboya = new arraylist<>(); arraylist listdataid = new arraylist<>(); arraylist listdatanumber = new arraylist<>(); random secilmiskisi ; int secilmissayı; @override public void onreceive(context context, intent intent) { mdatabasehelper = new databasehelper(context); cursor data = mdatabasehelper.getdata(); while(data.movetonext()){ listdataid.add(data.getstring(0)); listdata.add(data.getstring(1)); listdatanumber.add(data.getstring(2)); listdataoran.add(data.getstring(3)); listdataboya.add(data.getstring(4));} secilmiskisi = new random(); secilmissayı = secilmiskisi.nextint(listdataid.size()) + 0; toast.maketext(context, "alarm !!!!!!!!!!", toast.length_long).show(); cancelalarm(context); // setalarm(context); if(!listdataboya.contains("#1eac02")){ string table = "people_table"; contentvalues productdetailscontentvalues = new contentvalues(); productdetailscontentvalues.put("boya", "#1eac02"); string = " id = " + listdataid.get(secilmissayı); mdatabasehelper.update(table, productdetailscontentvalues, , null); intent yesreceive = new intent(); yesreceive.setaction(appconstant.yes_action); pendingintent pendingintentyes = pendingintent.getbroadcast(context, 12345, yesreceive, pendingintent.flag_update_current); intent intenttt = new intent(context,anamenu.class); pendingintent pintent = pendingintent.getactivity(context, 0, intenttt, 0); intent yesreceive2 = new intent(); yesreceive2.setaction(appconstant.stop_action); pendingintent pendingintentyes2 = pendingintent.getbroadcast(context, 12345, yesreceive2, pendingintent.flag_update_current); // build notification // actions fake notification noti = null; if (android.os.build.version.sdk_int >= android.os.build.version_codes.jelly_bean) { noti = new notification.builder(context) .setticker(" size bir bildirim yolladı.") .setcontenttitle("") .setcontenttext(listdata.get(secilmissayı)+" arama zamanı") .setsmallicon(r.drawable.familyiiii) .addaction(r.drawable.cal, "ara", pendingintentyes) .addaction(r.drawable.se, "daha sonra", pendingintentyes2) .setcontentintent(pintent).getnotification(); } // .setticker(" size bir bildirim yolladı.").setsmallicon(r.drawable.familyiiii) // .setsubtext("bu mesaj ile artık" + isimler.get(random) + " arayacağın bir görevin oldu.") notificationmanager notificationmanager = (notificationmanager) context.getsystemservice(notification_service); noti.flags |= notification.flag_auto_cancel; notificationmanager.notify(0, noti); setalarm(context); }else if (listdataboya.get(secilmissayı) != "#1eac02" ){ string table = "people_table"; contentvalues productdetailscontentvalues = new contentvalues(); productdetailscontentvalues.put("boya", "#1eac02"); string = " id = " + listdataid.get(secilmissayı); mdatabasehelper.update(table, productdetailscontentvalues, , null); intent yesreceive = new intent(); yesreceive.setaction(appconstant.yes_action); pendingintent pendingintentyes = pendingintent.getbroadcast(context, 12345, yesreceive, pendingintent.flag_update_current); intent intenttt = new intent(context, anamenu.class); pendingintent pintent = pendingintent.getactivity(context, 0, intenttt, 0); intent yesreceive2 = new intent(); yesreceive2.setaction(appconstant.stop_action); pendingintent pendingintentyes2 = pendingintent.getbroadcast(context, 12345, yesreceive2, pendingintent.flag_update_current); // build notification // actions fake notification noti = null; if (android.os.build.version.sdk_int >= android.os.build.version_codes.jelly_bean) { noti = new notification.builder(context) .setticker(" size bir bildirim yolladı.") .setcontenttitle("") .setcontenttext(listdata.get(secilmissayı)+" arama zamanı") .setsmallicon(r.drawable.familyiiii) .addaction(r.drawable.cal, "ara", pendingintentyes) .addaction(r.drawable.se, "daha sonra", pendingintentyes2) .setcontentintent(pintent).getnotification(); } // .setticker(" size bir bildirim yolladı.").setsmallicon(r.drawable.familyiiii) // .setsubtext("bu mesaj ile artık" + isimler.get(random) + " arayacağın bir görevin oldu.") notificationmanager notificationmanager = (notificationmanager) context.getsystemservice(notification_service); noti.flags |= notification.flag_auto_cancel; notificationmanager.notify(0, noti); setalarm(context); }while (listdataboya.get(secilmissayı) == "#1eac02"){////here , problem. string table = "people_table"; contentvalues productdetailscontentvalues = new contentvalues(); productdetailscontentvalues.put("boya", "#1eac02"); string = " id = " + listdataid.get(secilmissayı); mdatabasehelper.update(table, productdetailscontentvalues, , null); intent yesreceive = new intent(); yesreceive.setaction(appconstant.yes_action); pendingintent pendingintentyes = pendingintent.getbroadcast(context, 12345, yesreceive, pendingintent.flag_update_current); intent intenttt = new intent(context, anamenu.class); pendingintent pintent = pendingintent.getactivity(context, 0, intenttt, 0); intent yesreceive2 = new intent(); yesreceive2.setaction(appconstant.stop_action); pendingintent pendingintentyes2 = pendingintent.getbroadcast(context, 12345, yesreceive2, pendingintent.flag_update_current); // build notification // actions fake notification noti = null; if (android.os.build.version.sdk_int >= android.os.build.version_codes.jelly_bean) { noti = new notification.builder(context) .setticker("aynikİŞİaynikİŞİaynikİŞİaynikİŞİaynikİŞİaynikİŞİ") .setcontenttitle("aynikİŞİaynikİŞİaynikİŞİaynikİŞİaynikİŞİ") .setcontenttext(listdata.get(secilmissayı)+" arama zamanı") .setsmallicon(r.drawable.familyiiii) .addaction(r.drawable.cal, "ara", pendingintentyes) .addaction(r.drawable.se, "daha sonra", pendingintentyes2) .setcontentintent(pintent).getnotification(); } // .setticker(" size bir bildirim yolladı.").setsmallicon(r.drawable.familyiiii) // .setsubtext("bu mesaj ile artık" + isimler.get(random) + " arayacağın bir görevin oldu.") notificationmanager notificationmanager = (notificationmanager) context.getsystemservice(notification_service); noti.flags |= notification.flag_auto_cancel; notificationmanager.notify(0, noti); setalarm(context); }
this first time activity has created :
i want change notification text when selected number"s line (random number)is green.
string subtext[]={"text one","text two","text three","text four"......}; int ran=new random().nextint(4);
android.app.notification notif = new android.app.notification.builder(getapplicationcontext()) .setcontenttitle("m-educate welcomes digital era of learning") .setsubtext(subtext[ran]) .setsmallicon(r.drawable.icn_app_icon) .setlargeicon(icon) .setcontentintent(pendingintent) .setsound(alarmsound) .build(); notificationmanager notificationmanager = (notificationmanager) getapplicationcontext().getsystemservice(context.notification_service); notificationmanager.notify(0, notif);
note : set texts in array , set random text each time fire notification
Comments
Post a Comment