S
S
ShanderYO2014-07-09 17:14:51
Android
ShanderYO, 2014-07-09 17:14:51

How to make Notification in android be a link to the application?

Good afternoon!
I'm trying to make it so that when the application window is minimized, a notification is sent, which would hang in the status bar until the application was closed and at the same time be a link to the application to return to it. It seems that everything works, except that when you click on the notification, the application does not open.
I do it like this:

Intent notificationIntent = new Intent(this, CordovaActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(NOTIFY_ID, notification);

The app is developed with phongap.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ShanderYO, 2014-07-10
@ShanderYO

The problem was solved by getting the intent like this:

PackageManager pm = getPackageManager();
        Intent notificationIntent = pm.getLaunchIntentForPackage(getApplicationContext().getPackageName());

For what reason the manual indication of the Activity class does not work is not clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question