我正在发送带有 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/