Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Android WebView need permissions for opening external URLs?

Tags:

I was trying the following example, but with external URLs: Using WebViews

The example shows how to load an HTML file from assets folder (file:// url) and display it in a WebView.

But when I try it with external URLs (like http://google.com), I am always getting a "Website Not Available" error. Android's built-in browser is able to access all external URLs.

I suspect that it has something to do with permissions, but wasn't able to confirm it.

like image 955
Tahir Akhtar Avatar asked Oct 13 '08 07:10

Tahir Akhtar


People also ask

Does Chrome use Android WebView?

No, Chrome for Android is separate from WebView. They're both based on the same code, including a common JavaScript engine and rendering engine.

How do you prevent the WebView from invoking the device's web browser when a redirection occurs in the WebView?

To detect and intercept any redirection from WebView , we can use shouldOverrideUrlLoading and return true if it is supported to redirect into native page so that WebView stop the URL redirection in the web page and stay in the current page.

Should Android System WebView be enabled?

The short answer to this question is yes, you do need Android System WebView. There is one exception to this, however. If you're running Android 7.0 Nougat, Android 8.0 Oreo, or Android 9.0 Pie, you can safely disable the app on your phone without suffering adverse consequences.

Is Android WebView deprecated?

This interface was deprecated in API level 12. This interface is now obsolete.


1 Answers

I found out the answer myself.

The permission name is android.permission.INTERNET.

Adding following line to the AndroidManifest.xml (nested directly in tag) did the trick:

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

The file can also be edited graphically in Eclipse plugin through permissions tab.

like image 99
Tahir Akhtar Avatar answered Oct 02 '22 12:10

Tahir Akhtar