简体   繁体   中英

How to get webview url in android phonegap application?

I'm developing a PhoneGap application in android. in some cases the application connects to external web pages through 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. so, there is a way to get the url to which we are connected with 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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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