[英]How to add Android intent to open google maps in Cordova/Ionic project?
Android API 30 (Android 11) 需要在應用清單中定義的額外權限才能打開其他應用(在我的例子中是 Google 地圖)。 但是,如果<manifest>
元素在 Ionic/Cordova 項目中不可用,我如何才能在我的項目中獲得此權限? 我有一個config.xml
文件,其中列出了 Android 和 iOS 的權限,但我不知道在哪里添加此權限。
其他人表示此 API 更改需要在<manifest>
添加權限
在我的 Ionic 5 項目中,我只能編輯一個如下所示的config.xml
文件:
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
<queries>
<package android:name="com.google.android.apps.maps" />
</queries>
</edit-config>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<allow-intent href="market:*" />
我已經嘗試添加建議的<queries>
元素,但這不起作用。 我正在單擊 UI 中的地址並使用 Ionic Launch Navigator 插件打開 Google 地圖。 它適用於 Android API 29 但不適用於 API 30。
我應該如何添加在 Android 中打開 Google 地圖的權限?
window.open(URL)
可在 Android 11 上運行以打開 Google 地圖,而無需更改權限或 API 密鑰。 請參閱幫助文章。
文章解釋了如何構建URL
以跨平台方式打開谷歌地圖,並支持查找位置和導航。 我不必弄亂權限或 AndroidManifest.xml 或 Cordova 元素。
在挖掘過程中,我使用了 Ionic 建議的Launch Navigator
插件,它以稍微不同的方式打開 Google 地圖,並且由於 Android 11 權限更改,此插件現在需要一個 Intent 權限,我無法弄清楚並放棄了按 URL 啟動的格式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.