I built a Cordova app that shows a notification on Android. When the notification is clicked and the app was closed in the meantime I want the app (the cordova activity) to be started again.
This is how I build the notification in a Cordova Android plugin:
Context context = this.cordova.getActivity();
Intent resultIntent = new Intent(context, CordovaActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);
Notification noti = new Notification.Builder(context)
.setContentTitle("MyApp")
.setContentText("foobar")
.setContentIntent(pIntent)
.build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
The notification shows up correctly, but doesn't start my app when clicking on it. I am not sure what class to provide for the Intent.
How do I have to create the notification to make this work?