Java – How do I get the WebView URL in the Android Phonegap app?

How do I get the WebView URL in the Android Phonegap app?… here is a solution to the problem.

How do I get the WebView URL in the Android Phonegap app?

I’m working on a PhoneGap app for Android.
In some cases, the application connects to an external web page over the Internet.
Since users may click links in web pages and go to sites that are not allowed, I need to track changes to the cordova webview URL.
So, is there a way to get the URL of our connection to PhoneGap?

Code sample:

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

Solution

I found it!

String WebViewUrl = appView.getUrl()

Related Problems and Solutions