I have a timer that creates a notification on completion. Clicking on the notification should lead to an activity called TimerActivity. I create 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 the activity doesn't open, the notification just autocancels.
On further investigation, it's only TimerActivity that won't open like this. If I change the intent to open say SttingsActivity.class, it works as it should. TimerActivity in the 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's defined like any of these other activities that work/can be opened by clicking on a notification