如果打开应用程序,则无效的通知意图不起作用
请告知,我们将发送推送通知,其中包含peNDINTENT的URL以for AddAction按钮。 AddAction按钮打开APP的主动脉,并将网络视频定向到WebView中的URL。当应用程序关闭时,此序列(pendingIntent)可以很好地工作,但是当它打开时,通知就位于那里,并在已经查看的页面/活动中打开该应用程序,而不是新的Activity/Page。
下面给出了我们的悬念代码,
int m = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
int requestID = (int) System.currentTimeMillis();
int notification_id=m;
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("uri", uri);
intent.putExtra("notification_id", notification_id);
/ntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, requestID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
请指导我们是我们出错的地方。
Please be informed we are sending push notification with a URl attached to pendingIntent for addAction button. AddAction button opens the mainactivity of app and directs to url in the webview. This sequence (pendingintent) works perfectly when app is closed, but when it is open, notification just stands there and opens the app in its already viewed page/activity rather than the new activity/page.
Our pendingIntent code is given below
int m = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
int requestID = (int) System.currentTimeMillis();
int notification_id=m;
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("uri", uri);
intent.putExtra("notification_id", notification_id);
/ntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, requestID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Please guide us as where we are going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试
以获取更多详细信息
https://developer.android.com/training.com/training/notify-user-notify-user-notify-user-notify-user-notify-user /导航
Try this
For more details
https://developer.android.com/training/notify-user/navigation