Frage

I want to load the google maps direction link to a webview inside the app. But when i load them it forces me to choose with what app it should open the direction.

webview = (WebView) findViewById(R.id.webView);
String url = String.format("http://maps.apple.com/maps?saddr=%f,%f&daddr=%f,%f", getIntent().getDoubleExtra("start_lat", 0),
             getIntent().getDoubleExtra("start_lng", 0),
             getIntent().getDoubleExtra("end_lat", 0),
             getIntent().getDoubleExtra("end_lng", 0));
webview.loadUrl(url);

This forces me to choose if i want to open with google maps or with the phone browser app. I want to let the app to load the direction url in my app, not an external app.

War es hilfreich?

Lösung

You should use

http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView,java.lang.String)

And override the loading of the URL to continue loading it within the webview.

Andere Tipps

You have to implement webviewclient and override the url loading

check this solution

https://stackoverflow.com/a/11859770/3518278

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top