android - 在android中打开通知时页面不刷新

标签 android android-intent android-notifications android-pendingintent

我正在发送带有 Intent 的预订 ID,然后包含详细信息的页面应使用与该预订 ID 相关的数据进行刷新。 问题是,如果用户位于详细信息页面并且收到通知,则数据不会刷新。

当我将启动模式添加为 SINGLETASK 时,就会出现问题。这是 Intent 代码:

 Intent intent = new Intent(getApplicationContext(), MyJobsActivity.class);
 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 intent.putExtra("idIs", bookingId);
 intent.setAction(bookingId);
 pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

我尝试了几个不同的 Intent 标志,但也不起作用:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

PendingIntent.FLAG_CANCEL_CURRENT

最佳答案

更新您的标志

 notificationIntent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT

此标志将 Activity 置于最前面并调用 onResume 方法,以便您可以在单击通知后刷新其中的数据。

关于android - 在android中打开通知时页面不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62773124/

相关文章:

android - Robolectric:如何测试包含 SherlockFragment 的 Activity ?

android - 测试 Android 广播时如何包含额外的包?

android - 如何区分我的通知何时通过 Dismissed all 按钮而不是滑动关闭来关闭?

Android Parse SDK - 保护凭据

android - 无法在未调用 Looper 准备的线程内创建处理程序

android - 为什么android中有ListVIew?

android - Activity 过渡无法正常使用背景颜色

android - 在 Android 中访问和修改 Wifi 状态

android - 取消通知时应用程序在恢复时崩溃

android - 如何在 Android 5.0 Lollipop 中关闭固定屏幕时收到通知?