简体   繁体   English

如何在android phonegap应用程序中获取webview url?

[英]How to get webview url in android phonegap application?

I'm developing a PhoneGap application in android. 我正在android中开发一个PhoneGap应用程序。 in some cases the application connects to external web pages through internet. 在某些情况下,应用程序通过Internet连接到外部网页。 Since the user may click on links in web pages and go to sites that are not allowed, I need to keep track of changes of cordova webview url. 由于用户可能会点击网页中的链接并转到不允许的网站,因此我需要跟踪cordova webview网址的更改。 so, there is a way to get the url to which we are connected with PhoneGap? 那么,有办法获得我们与PhoneGap连接的网址吗?

code example: 代码示例:

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" 
     }
 }

我找到了!

String WebViewUrl = appView.getUrl()

call loadurl before using appView 在使用appView之前调用loadurl

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

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

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

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