我正在使用谷歌Map在Map上列出我附近的商店。如何获得一个弹出窗口,当我选择其中一个商店时,它将选择手机上下载的Map应用程序之一。当我研究它时,我找不到任何结果。例如,当我们想要打开PDF时,设备上会出现一个弹出窗口,告诉我们要选择哪个应用程序。我想做类似的事情。例如,现在我的手机上有Yandex和谷歌Map应用程序。2我必须做一个弹出窗口来选择其中一个。3下面的代码只直接打开谷歌Map应用程序。
fun openMapApp(office: StoreOffice) {
weakReference.get()?.run {
val location = "${office.latitude},${office.longitude}"
val uri = Uri.parse("geo:${location}?q=${location}(${Uri.parse(office.vendorName)})")
val intent = Intent(Intent.ACTION_VIEW, uri)
val chooser = Intent.createChooser(intent, resources.getString(R.string.chooser_title))
try {
startActivity(chooser)
} catch (e: ActivityNotFoundException) {
AlertDialog.Builder(requireContext())
.setTitle(R.string.common_warning)
.setMessage(R.string.app_not_found_message)
.build()
}
}
}
1条答案
按热度按时间qv7cva1a1#
从你的问题来看,我相信你想要一种从手机上的导航应用列表中选择导航应用的方法。
从问题Android导航应用的Intent选择器中查看this answer,应该会有帮助。