Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android WebView internet access problem, because of proxy?

Tags:

android

Here is my problem:

Emulator(Android 2.2) is able to access internet through browser. (I am behind a proxy so i set the proxy first)

but when i create a webview app, seems like it can not access the internet by webview.

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

is set up. So I am afraid it's because of the proxy.

Any clue ? Thanks.

like image 696
user822211 Avatar asked Jul 13 '11 01:07

user822211


People also ask

Which browser does WebView use?

Google combined WebView with Google Chrome for versions 7.0, 8.0 and 9.0. However, with Android 10.0, it went back to having it as a separate component. Users can update WebView in Android 10 through Google Play Store.

How do I enable cache in WebView?

This example demonstrate about How to enable app cache for webview in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

Is Android WebView deprecated?

Beginning October 5, 2021, Facebook Login will no longer support using Android embedded browsers (WebViews) for logging in users.


2 Answers

Try adding In OnCreate()

WebView.enablePlatformNotifications();

And adding the following permissions to the manifest

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

This should enable your webview to access the proxy info it needs. You may need to restart your emulator (hopefully not).

like image 80
Justin Shield Avatar answered Sep 27 '22 23:09

Justin Shield


For me, my apps cannot access webViews unless I specify a DNS server for my Android simulators. This is how I solve the issue in eclipse:

  • Eclipse > Preferences > Android > Launch:
  • Default emulator options:
  • dns-server 8.8.8.8

You must also add "-dns-server 8.8.8.8" for any Android Run Configurations already created.

  • Run > Run Configurations > Select Android Project > Target Tab > Additional Emulator Command Line Options:
  • Add "-dns-server 8.8.8.8" here.

Not sure if this will help with your issue, but hopefully it does.

like image 32
triad Avatar answered Sep 27 '22 23:09

triad