I checked all the possible SO questions regarding notification not opening activity.
Not Opening the New Activity After Clicking on the Notification Android
Clicking notification not opening app/activity
Open application after clicking on Notification
http://www.vogella.com/tutorials/AndroidNotifications/article.html
Below is my code :
Intent resultIntent = new Intent(MainApplication.this, HomeActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainApplication.this);
stackBuilder.addParentStack(HomeActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainApplication.this);
builder.setContentTitle(notifMessage.getTitle())
.setContentText(notifMessage.getDescription())
.setAutoCancel(true);
builder.setContentIntent(resultPendingIntent);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(0, builder.build());
and in AndroidManifest
<activity
android:name=".HomeActivity"
android:configChanges="locale|layoutDirection"
android:screenOrientation="portrait"
android:exported="true"/>
And still I can't manage to open the activity from notification.
Any idea what is wrong, can the issue be that I'm doing all this from MainApplication (in the OneSignal.startInit
) and not from a service
Thanks