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
//  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

Popular posts from this blog

App Store Connect ITMS-90078: Missing Push Notification Entitlement - Your app appears to register with the Apple Push Notification service, but the app signature's entitlements do not include the "aps-environment"

RGPV CSE 8th Semester Soft computing Notes and Lectures

Facts about bb ki vines bhuvan bam