简体   繁体   English

无需休闲即可进行单项活动的通知意图

[英]Notification intent to single activity without recreation

I have webview application and I have two types of GCM notifications: "new thread" and "new reply to thread". 我有webview应用程序,并且有两种类型的GCM通知:“新线程”和“新回复线程”。 So when user clicks on one of notification, in this moment webview should open one of appropriate web page. 因此,当用户单击通知之一时,此时Webview应该打开适当的网页之一。 I applied 我申请了

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);

and added android:launchMode="singleTask" to activity manifest. 并将android:launchMode="singleTask"到活动清单中。 That how I avoid webview recreation and whole process of reloading page. 那就是我如何避免webview重新创建页面的整个过程。 But I have a problem: how to listent Intent in MainActivity to further webview location changes? 但是我有一个问题:如何在MainActivity中列出Intent以进一步更改Webview的位置?

If Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP 如果是Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP is not flags that I need, then please tell me how avoid full webview recreaction in void onCreate(Bundle savedInstanceState) ? Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP不是我需要的标志,然后请告诉我如何避免在void onCreate(Bundle savedInstanceState)完全Webview void onCreate(Bundle savedInstanceState) savedInstanceState == null in all times, how can I save last webview instance? savedInstanceState == null一直以来,如何保存上一个Webview实例?

@Override
protected void onNewIntent(Intent intent)

Is the solution. 是解决方案。 Thanks to pskink 感谢pskink

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM