Internet permission not working in oreo and pie

It probably because you're using http. Starting from Android O, you need to use https instead of http or you'll have an error Cleartext HTTP traffic to * not permitted. So, you need to create a configuration to allow this. You can refer it to Opt out of cleartext traffic

Details of documentation:

Note: The guidance in this section applies only to apps that target Android 8.1 (API level 27) or lower. Starting with Android 9 (API level 28), cleartext support is disabled by default.

Applications intending to connect to destinations using only secure connections can opt-out of supporting cleartext (using the unencrypted HTTP protocol instead of HTTPS) to those destinations. This option helps prevent accidental regressions in apps due to changes in URLs provided by external sources such as backend servers. See NetworkSecurityPolicy.isCleartextTrafficPermitted() for more details.

For example, an app may want to ensure that all connections to secure.example.com are always done over HTTPS to protect sensitive traffic from hostile networks.

res/xml/network_security_config.xml:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">secure.example.com</domain>
    </domain-config>
</network-security-config>

.


You can also use android:usesCleartextTraffic="true" in your AndroidManifest.xml for your development mode but you should not use it in release mode. More details about it in Android Developer Blog, here the excerpts:

Block cleartext traffic in production

To protect the installed base of your app against regressions to cleartext traffic, declare android:usesCleartextTraffic=”false” attribute on the application element in your app’s AndroidManifest.xml. This declares that the app is not supposed to use cleartext network traffic and makes the platform network stacks of Android Marshmallow block cleartext traffic in the app. For example, if your app accidentally attempts to sign in the user via a cleartext HTTP request, the request will be blocked and the user’s identity and password will not leak to the network.

You don’t have to set minSdkVersion or targetSdkVersion of your app to 23 (Android Marshmallow) to use android:usesCleartextTraffic. On older platforms, this attribute is simply ignored and thus has no effect.

Please note that WebView does not yet honor this feature.

And under certain circumstances cleartext traffic may still leave or enter the app. For example, Socket API ignores the cleartext policy because it does not know whether the data it transmits or receives can be classified as cleartext. Android platform HTTP stacks, on the other hand, honor the policy because they know whether traffic is cleartext.

Google AdMob is also built to honor this policy. When your app declares that it does not use cleartext traffic, only HTTPS-only ads should be served to the app.

Third-party network, ad, and analytics libraries are encouraged to add support for this policy. They can query the cleartext traffic policy via the NetworkSecurityPolicy class.


If your URL start's with http then you have to use it is used in Android Pie i.e API level 28

android:usesCleartextTraffic="true"

in your manifest inside application tag as an attribute


URL starting with http:// you need to add the following attribute in your manifest file inside application tag.

android:usesCleartextTraffic="true"

Add below line of code in AndroidManifest.xml file:

android:usesCleartextTraffic="true"

Although, this will give you the warning: Warning when we add android:usesCleartextTraffic="true"

It'll solve the problem for now. But you should migrate to 'HTTPS' as soon as possible.