I have a timer that generates a notification upon completion. Clicking on a notification should result in an activity called TimerActivity. I am creating a notification like this:
mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(completeNotificationIcon)
.setContentTitle(completeNotificationTitle)
.setContentText(completeNotificationText)
.setTicker(completeNotificationTicker)
.setAutoCancel(true);
Intent notificationIntent = new Intent(this, TimerActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mBuilder.setContentIntent(contentIntent);
mNotificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
The problem is that the activity does not open, the notification just starts automatically.
With further research, it will only be TimerActivity, which will not open like that. If I change my intention to open, say, SttingsActivity.class, it works as it should. TimerActivity in manifest:
<activity
android:name=".TimerActivity"
android:parentActivityName=".MainActivity"
android:label="@string/action_timer"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
But it is defined as any of these other actions that work / can be opened by clicking on the notification
source
share