Use any available Maps app, not just explicitly Google Maps.

This commit is contained in:
Azuo 2021-08-16 12:39:11 +08:00
parent 218dae8cc2
commit 7b93548b0b

View File

@ -45,14 +45,14 @@ object IntentHelper {
}
fun getGoogleMapsIntentFromAddress(context: Context, address: String): Intent {
val gmmIntentUri: Uri = Uri.parse("geo:0,0?q=$address")
val gmmIntentUri: Uri = Uri.parse("geo:0,0?q=${Uri.encode(address)}")
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
mapIntent.`package` = "com.google.android.apps.maps"
//mapIntent.`package` = "com.google.android.apps.maps"
return if (mapIntent.resolveActivity(context.packageManager) != null) {
mapIntent
} else {
val map = "http://maps.google.co.in/maps?q=$address"
val map = "https://www.google.com/maps/search/?api=1&query=${Uri.encode(address)}"
val i = Intent(Intent.ACTION_VIEW, Uri.parse(map));
i
}