mortar-flow-example-app
mortar-flow-example-app copied to clipboard
Issues with re-launching the activity from a notification tray intent.
So...I added a button that just calls this method from MainView:
private void createNotification(Context context) {
Intent intent = new Intent(context, FlowMortarExampleActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// 0 is the request code.
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("New notification")
.setContentText("Caption")
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// 0 is the ID of the notification.
notificationManager.notify(0, notificationBuilder.build());
}
When you then click on the notification, the app crashes:
http://pastebin.com/raw.php?i=nMmEj2T4
Any thoughts? I can submit the code that adds the button, creates the notification (can create a PR).
btw - this may be a more accurate StackTrace: http://pastebin.com/raw.php?i=8iT49hZF
I added a null check on config in ActionBarOwner.update.
Thanks for the example. I have had notifications working so it might be as simple has having a unique scope (as pointed out in the PR). I'll have to dig into this to figure out what's going on.