Reputation: 9924
Is there an API for opening coordinates in Android which would show the default? Something like:
I'm talking about this one:
Right now I do it like this:
fun startNavigation() {
val data = intent.getSerializableExtra(CheckInStartActivity.KEY_DATA) as Data
val location = data.location as Location
val latitude = location.lat
val longitude = location.lng
val uriWaze = Uri.parse("https://waze.com/ul?ll=$latitude,$longitude&navigate=yes")
val intentWaze = Intent(Intent.ACTION_VIEW, uriWaze)
intentWaze.setPackage("com.waze")
val uriGoogle = "google.navigation:q=$latitude,$longitude"
val intentGoogleNav = Intent(Intent.ACTION_VIEW, Uri.parse(uriGoogle))
intentGoogleNav.setPackage("com.google.android.apps.maps")
val title = getString(R.string.choose_navigation_app)
val chooserIntent = Intent.createChooser(intentGoogleNav, title)
val arr = arrayOfNulls<Intent>(1)
arr[0] = intentWaze
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arr)
startActivity(chooserIntent)
}
but this solution:
Is there a general way/API to do such thing? Or is this coded for each application one by one on the screenshot I linked with the buttons and everything manually?
Upvotes: 0
Views: 168