如果打开应用程序,则无效的通知意图不起作用

发布于 2025-02-12 05:42:04 字数 794 浏览 1 评论 0原文

请告知,我们将发送推送通知,其中包含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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

才能让你更想念 2025-02-19 05:42:04

请尝试

PendingIntent notifyPendingIntent = PendingIntent.getActivity(
    this, 0, notifyIntent,
    PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

以获取更多详细信息

https://developer.android.com/training.com/training/notify-user-notify-user-notify-user-notify-user-notify-user /导航

Try this

PendingIntent notifyPendingIntent = PendingIntent.getActivity(
    this, 0, notifyIntent,
    PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

For more details

https://developer.android.com/training/notify-user/navigation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文