【问题标题】:Notification intent to single activity without recreation没有娱乐的单一活动的通知意图
【发布时间】:2015-08-08 16:46:18
【问题描述】:

我有 webview 应用程序,我有两种类型的 GCM 通知:“新线程”和“新线程回复”。因此,当用户单击通知之一时,此时 webview 应该打开一个适当的网页。 我申请了

Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT);

并将android:launchMode="singleTask" 添加到活动清单中。这就是我如何避免 webview 重新加载和重新加载页面的整个过程。但是我有一个问题:如何监听 MainActivity 中的 Intent 以进一步改变 webview 位置?

如果 Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP 不是我需要的标志,那么请告诉我如何避免在 void onCreate(Bundle savedInstanceState) 中进行完整的 webview 娱乐? savedInstanceState == null 一直以来,如何保存最后一个 webview 实例?

【问题讨论】:

  • 你的应用在后台还是被杀死了?
  • 你想要 onNewIntent 吗?

标签: android android-intent webview notifications


【解决方案1】:
@Override
protected void onNewIntent(Intent intent)

是解决办法。感谢pskink

【讨论】:

    猜你喜欢
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    相关资源
    最近更新 更多