I have some trouble, and can not find any answers I focus on several points.
I have a service, it checks for this information on the site and alerts the user to a new notification. When users click on this notification, they should be brought to an activity (I will talk about this comment);
However, if I click on the notification within the app, so do not if I click on the notification outside of the app, the app opens to the last activity was shown before closing .
My code is here to display the notification:
notice n; // Notification from site .... intent nIntent = new intent (Intent.ACTION_MAIN); NIntent.setClass (getApplicationContext (), CommentActivity.class); NIntent.putExtra ("Activity_ID", NFFIDID); NIntent.addFlags (intestine. FLAG_ACTIVITY_NEW_TASK | effect. FLAG_ACTIVITY_REORDER_TO_FRONT); Pending patent Prntent = Lmbitintentkget activity (getApplicationContext (), 0, Anaintent, Lmbitinntent. FLAG_UPDATE_CURRENT; pending INNT.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = New Notification Builder (FlankNotificationService.this) .setSmallIcon (R.drawable.ic_launcher) .setContentTitle (n.getTitle ()) .setContentText (n.getText ()) .setContentInfo (arg0.getNotificationAmount () + "notification" + (arg0.getNotificationAmount () == 1. ".": "S.")) .setContentIntent (pIntent); Notification mm = mbilder.jetnotification (); Mm.flags = Notice. FLAG_ONLY_ALERT_ONCE | Notification.FLAG_AUTO_CANCEL; Mm.tickerText = n.getText (); .... mnm Notificed (1558, mm); So instead of opening remarks of activity, it either will resume (if the app is not open) or open (nothing if app) < P> Thank you.
Edit 1: Intent to add meaning. The flag FLAG_ACTIVITY_REORDER_TO_FRONT still does not fix the problem.
Edit 2: I found the reason for my problem (which was a silly cause). When the comment activation starts, if it does not get any data from the saved instance or intent. Gatextra, it will only be closed. The reason is that I did not think about it earlier because it did not even show the infection. After fixing the intent.getExtra problem, it works now thanks to all the replies.
You may want to add a flag to your intent. This will ensure that CommentActivity resumes and active activity when the intent is controlled.
No comments:
Post a Comment