Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Webview在每次调用时都保留旧Url_Android_Webview - Fatal编程技术网

Android Webview在每次调用时都保留旧Url

Android Webview在每次调用时都保留旧Url,android,webview,Android,Webview,我正在使用C2Dm服务将通知推送到我的应用程序。我有一个活动,其中只包括一些企业设计元素和网络视图 当我第一次启动应用程序并将url推送到设备时,用户会在通知栏中收到通知。如果他单击通知,我将创建一个PendingEvent来启动webview活动 在这里之前,一切都很好。但该应用程序一直打开它通过C2DM消息获得的第一个URL,并且从未显示新的URL。url本身通过bundle extra传递 下面是为通知创建挂起意图的代码: Intent intent = WebviewActivi

我正在使用C2Dm服务将通知推送到我的应用程序。我有一个活动,其中只包括一些企业设计元素和网络视图

当我第一次启动应用程序并将url推送到设备时,用户会在通知栏中收到通知。如果他单击通知,我将创建一个PendingEvent来启动webview活动

在这里之前,一切都很好。但该应用程序一直打开它通过C2DM消息获得的第一个URL,并且从未显示新的URL。url本身通过bundle extra传递

下面是为通知创建挂起意图的代码:

    Intent intent = WebviewActivity.asIntent(context, getUrlWithAttachedAccesskey(notification.getUrl()), new Bundle()); // just a static method to wrap the bundle correctly
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Notification notification = new Notification(R.drawable.appiconmenu, message, System.currentTimeMillis());
    PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);

    notification.setLatestEventInfo(context, title, message, pIntent);
    notificationMan.notify(getNextNotificationId(), notification);
在WebviewActivity站点上,代码如下所示:

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    if(extras != null) {
        String url = intent.getExtras().getString(DESTINATION_URL);     
        Log.i(TAG, "Loading url: " + url);
        wbVwBrowser.loadUrl(url);
    }
我的意图有问题吗?我必须用不同的称呼吗?是网络视图吗

更新:

    Intent intent = new Intent(sender, WebviewActivity.class);      
    extras.putString(DESTINATION_URL, destUrl);
    intent.putExtras(extras);

    return intent;
尝试此标志:

Intent.FLAG_ACTIVITY_CLEAR_TOP
而不是:

Intent.FLAG_ACTIVITY_NEW_TASK

请看本指南:


您必须在活动中重写onNewIntent(),才能访问包含新URL的PendingEvents捆绑包。getIntent()将始终返回启动活动的原始意图。

onNewIntent永远不会被调用。“对于在其包中将启动模式设置为“singleTop”的活动,或者如果客户端在调用startActivity(Intent)时使用了FLAG_Activity_SINGLE_TOP标志,则会调用此函数。”;Notification Notification=new我使用以下代码:Notification(R.drawable.appiconmenu,message,System.currentTimeMillis());pendingent pIntent=pendingent.getActivity(上下文,0,意图,0);但是onNewIntent仍然没有被调用。请尝试在没有静态包装方法的情况下使用捆绑注入url!