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 地圖的權限?
uj5u.com熱心網友回復:
window.open(URL)將在 Android 11 上運行,無需更改權限或 API 密鑰即可打開 Google 地圖。請參閱幫助文章。
文章解釋了如何構建URL以跨平臺的方式打開谷歌地圖,并支持查找位置和導航。我不必弄亂權限或 AndroidManifest.xml 或 Cordova 元素。
在挖掘程序中,我使用了 Ionic 建議的Launch Navigator插件,它以稍微不同的方式打開 Google 地圖,并且由于 Android 11 權限更改,此插件現在需要一個 Intent 權限,我無法弄清楚并放棄了按 url 格式啟動。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/363297.html
標籤:安卓 科尔多瓦 离子框架 android-11
