notifications - Android BroadcastReceiver does not start -


i'm trying start notification @ given time. entered broadcastreceiver notification not start. maybe mistake in manifest? thank help.

 public void to_reminder(view v)  {       calendar cal=calendar.getinstance();      cal.set(calendar.hour_of_day, 15);       cal.set(calendar.minute, 16);         cal.set(calendar.second, 0);      cal.set(calendar.millisecond, 0);       alarmmanager = (alarmmanager) getsystemservice(alarm_service); intent = new intent(this, notifica.class); pendingintent pi = pendingintent.getservice(this, 0, i, 0); am.cancel(pi); am.setrepeating(alarmmanager.rtc_wakeup, system.currenttimemillis(), 24*60*60*1000 , pi);  } 

.

public class notifica extends broadcastreceiver {  @override public void onreceive(context context, intent arg1) {      shownotification(context); } private void shownotification(context context) {     pendingintent contentintent = pendingintent.getactivity(context, 0,             new intent(context, login.class), 0);      notificationcompat.builder mbuilder =             new notificationcompat.builder(context)             .setsmallicon(0)             .setcontenttitle("my notification")             .setcontenttext("hello world!");     mbuilder.setcontentintent(contentintent);     mbuilder.setdefaults(notification.default_sound);     mbuilder.setautocancel(true);      notificationmanager mnotificationmanager =     (notificationmanager) context.getsystemservice(context.notification_service);     mnotificationmanager.notify(1, mbuilder.build());  }   } 

.

 <!-- broadcast receiver --> <receiver android:name="reminder.notifica"></receiver>   </application> 

you need add pendingintent.getbroadcast instead of pendingintent.getservice. more details see this


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -