android webview open google maps app
Problem is:when i open the same site on my chrome browser it opens my google maps with the desired cordinates.. now im windering why my webview doesnt do it.
Before going to soulution comment this line
Solution: 1) if app iside
Before going to soulution comment this line
// private static final String DEBUG_TAG = "Web";
Solution: 1) if app iside
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// When user clicks a hyperlink, load in the existing WebView
if(url.contains("geo:")) {
Uri gmmIntentUri = Uri.parse(url);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
}
return true;
}
view.loadUrl(url);
return true;
}
2)if website inside
if(url.contains("https://www.google.com/maps/"))
{
Uri IntentUri = Uri.parse(url);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, IntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
}
return true;
}
Comments
Post a Comment