mortar-flow-example-app icon indicating copy to clipboard operation
mortar-flow-example-app copied to clipboard

Issues with re-launching the activity from a notification tray intent.

Open datermine opened this issue 8 years ago • 2 comments

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).

datermine avatar Oct 29 '15 21:10 datermine

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.

datermine avatar Oct 30 '15 17:10 datermine

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.

thorbenprimke avatar Nov 01 '15 22:11 thorbenprimke