0

I have a directory website when I use the mobile web browser the address links opens in the google app map nicely, then when try the same with my webview app it returns to the google map website so it cannot resolve my location....I want to open the links with the google map app...

I tried this code on the Urlhander.java:(doesn't work)

 public static boolean map(Activity mActivity, String url) {
    // When user clicks a hyperlink, load in the existing WebView
    if(url.contains("http://maps.google.com/"))
    {
        Uri IntentUri = Uri.parse(url);
        Intent mapIntent = new Intent(Intent.ACTION_VIEW, IntentUri);
        mapIntent.setPackage("com.google.android.apps.maps");

        if (mapIntent.resolveActivity(mActivity.getPackageManager()) != null) {
            mActivity.startActivity(mapIntent);
        }
        return true;
    }
    return false;
}
  • You should take a look at this question: http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android – Fedor Tsyganov Nov 24 '16 at 08:48

1 Answers1

0

Try using the snippet from Adding a WebView to Your Application:

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");

Don't forget to include the INTERNET permission:

< manifest ... >
    <uses-permission android:name="android.permission.INTERNET" />
    ...
< /manifest >

This Using a WebView to access Google Maps guide might also help.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
  • Thanks I resolve it. Now when click on the address link it opens the native app for maps but when i go back my webview is empty..it didnt keeps the page. – Karl Velez Nov 27 '16 at 17:48