我構建了一個顫振應用程式。我使用 url_launcher 包來導航社交鏈接和其他外部瀏覽器鏈接。它在安卓模擬器上完美運行。但是當我構建 apk 并將其安裝在手機上時,URL 沒有啟動。甚至網路影像也沒有顯示出來。
簡單地說,我的意思是顫振應用程式根本沒有互聯網訪問權限。我的問題是為什么相同的代碼可以完美地在模擬器上運行而不能在真實設備上運行?
我還檢查了android清單檔案。也沒有問題。這是android清單代碼
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sri_lanka">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
這是在真實手機上無法打開的圖示按鈕 [1]:
uj5u.com熱心網友回復:
我找到了一個解決方案:您需要在您的 android 清單中添加一些額外的編碼才能在真實設備上啟動 URL。也可以參考 url_launcher 檔案https://pub.dev/packages/url_launcher
請參閱此鏈接以獲取詳細資訊https://developer.android.com/training/package-visibility/use-cases#kotlin
示例影像
您需要在清單檔案中添加另一行代碼才能在 android mobile 上訪問互聯網。
就是這個=>
<uses-permission android:name="android.permission.INTERNET"/>
這是您需要添加到 android 清單中的代碼:清單檔案路徑 => android\app\src\main\AndroidManifest.xml
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/431574.html
