Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to set Internet permission for opening a website in Android?

Tags:

android

view

In my activity I have some links that when user click on it, WebView will open and load a page from Internet.

My Question is, do I have to set permission in manifest file for accessing Internet? Because when I run the program, emulator says web page is not available.

My code is:

final TextView tv01 = (TextView) findViewById(R.id.pck_01);


        final WebView wv = new WebView(this);
        tv01.setOnClickListener(new View.OnClickListener() {    
            @Override
            public void onClick(View v) {
                wv.loadUrl("http://www.stackoverflow.com");
                setContentView(wv);
            }
        });
like image 237
Hesam Avatar asked May 25 '11 20:05

Hesam


People also ask

Which permission is required for used internet in Android?

Note: Both the Internet and ACCESS_NETWORK_STATE permissions are normal permissions, which means they're granted at install time and don't need to be requested at runtime.

Why do you need to add this code uses-permission android name Android permission internet /> at AndroidManifest XML?

Lets say you are downloading an application which must not use internet at all and if you don't require any permission for that, it might be secretly putting data on some server. You need to explicitly put internet permission in AndroidManifest. xml, so user of your app will be aware of it.

What app permissions should I allow?

Only give your Android apps permission to access what they need to access on your device to provide the functionality you require from them. For example, it's natural that your weather app or navigation app will need access to your location to function properly.


1 Answers

Yes you will need to have the following permission added to the manifest to access and URL outside of the device:

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

Seems to be confirmed here as well:

Does Android WebView need permissions for opening external URLs?

like image 103
mag382 Avatar answered Sep 23 '22 15:09

mag382