3

我正在android中开发一个PhoneGap应用程序。在某些情况下,应用程序通过 Internet 连接到外部网页。由于用户可能会单击网页中的链接并转到不允许的站点,因此我需要跟踪 cordova webview url 的更改。那么,有一种方法可以获取我们与 PhoneGap 连接的 url 吗?

代码示例:

public class MyPhoneGapActivity extends DroidGap 
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        super.init();
        super.clearCache();
        super.clearHistory();
        super.appView.getSettings().setAppCacheEnabled(false);
        super.loadUrl("http://www.google.com");

            String WebViewUrl = ??  

            //I need WebViewUrl = "http://www.google.com" 
     }
 }
4

2 回答 2

4

我找到了!

String WebViewUrl = appView.getUrl()
于 2013-07-19T08:09:58.223 回答
-1

在使用 appView 之前调用 loadurl

super.loadUrl(" http://www.google.com ");

super.appView.getSettings().setAppCacheEnabled(false);

于 2013-09-04T12:00:00.937 回答