I built an flutter app. I used url_launcher package to navigate social links and other external browser links. And it was perfectly working on android emulator. But when I build the apk and install it on my mobile phone, URLs didn't launch. Even the network images aren't showing up.
Simply I mean the flutter app did not have internet access at all. My question is why the same code working on emulator perfectly and doesn't work on a real device?
I also checked android manifest file. There were no problems also. Here is the android manifest code
<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>
And here is the icon button that won't open on a real mobile [1]:
CodePudding user response:
I found a solution: You need to add some extra coding in to your android manifest to launch URLs on a real device. You can also refer to the url_launcher documentation https://pub.dev/packages/url_launcher
please refer to this link to get detailed information https://developer.android.com/training/package-visibility/use-cases#kotlin
And you need to add another line of code to manifest file in order to access internet on android mobile.
this is it =>
<uses-permission android:name="android.permission.INTERNET"/>
Here is the code you need to add in to the android manifest: manifest file path => 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>