0

I am trying to set permissions to access the internet on my app but the permission manager won't let me do it. Therefore, I can't run web-view. The code below runs fine on Nougat. What is going on?

Here's is part of my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.droid_controls">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".WebViewActivity"
            android:screenOrientation="landscape"></activity>
        <activity

Here is the code to for the web-view:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);

    WebView browser = findViewById(R.id.webview);
    browser.loadUrl("http://www.google.com");
}

and the html:

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

When I go to the app manager and try to change the permissions and tap on "Allowed" does not do anything. The strange part is the if I look at all permissions of the app, I see that matches my manifest. See the screenshots:

app manager

The permissions match the manifest.

all permissions

code not running

Tapping on anything is goes no where, and web-view does not load the page. What is going on?

thank you.

gmmo
  • 2,577
  • 3
  • 30
  • 56

2 Answers2

0

INTERNET and ACCESS_NETWORK_STATE are normal permissions. They are granted automatically on installation, when your device runs on Android 6.0 or higher and your targetSdkVersion is 23 or higher.

See also the permissions documentation and this SO post

memres
  • 439
  • 2
  • 9
  • Thanks but still not working. The web-view does NOT load the web-site. The same exact code runs find on Nougat. Any cluse? – gmmo Feb 10 '21 at 17:19
0

Never mind, this was the issue.

android:usesCleartextTraffic="true"

Android 8: Cleartext HTTP traffic not permitted

gmmo
  • 2,577
  • 3
  • 30
  • 56