Skip to content Skip to sidebar Skip to footer

Notification Activity Called By Alarmmanager Not To Pop Up When App Is Closed

For a custom reminder app, I'm using AlarmManager and PendingIntent to set a specific time for my Notification to pop up. I have my NotificationManager in ReceiverActivity @Ove

Solution 1:

Define your AlarmManager's PendingIntent to be received by a BroadcastReceiver

Intent i = newIntent(context, YourReceiver.class);
PendingIntent alarmPendingIntent= PendingIntent.getBroadcast(context, 0, i,
            PendingIntent.FLAG_UPDATE_CURRENT);

Then

publicclassYourReceiverextendsBroadcastReceiver {

    @OverridepublicvoidonReceive(Context context, Intent intent) {
        // use a BUILDER all this is deprecatedCharSequenceticker="You have notification";
        CharSequencecontentTitle="My Reminder";
        CharSequencecontentText="Reminder Content";
        Notificationnotification=newNotification(R.drawable.notif_icon,
                ticker, System.currentTimeMillis());
        IntentnotificationIntent=newIntent(this,
                AlarmReceiverActivity.class);
        PendingIntentcontentIntent= PendingIntent.getActivity(context, 0,
            notificationIntent, 0);
        notification.setLatestEventInfo(context, contentTitle, contentText,
            contentIntent);
        // post notificationStringns= Context.NOTIFICATION_SERVICE;
        NotificationManagermNotificationManager= (NotificationManager)
                context.getSystemService(ns);
        finalintHELLO_ID=1;
        mNotificationManager.notify(HELLO_ID, notification);
    }
}

Post a Comment for "Notification Activity Called By Alarmmanager Not To Pop Up When App Is Closed"