6

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.

user822211
  • 343
  • 1
  • 6
  • 15

2 Answers2

9

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).

Justin Shield
  • 2,390
  • 16
  • 12
  • yes! it works ,and also needs to add , thank you very much – user822211 Jul 13 '11 at 02:40
  • yes! yes! yes! it works. How do you find out such things, really? My app was giving URL not found errorCode = -2 with webview for a particular service provider. Your change fixed it!! Thanks!! – vivek.m Sep 28 '11 at 13:37
  • 2
    This method is deprecated. Obsolete - platform notifications are always enabled. Enables platform notifications of data state and proxy changes. – Muhammad Mubashir Jan 11 '13 at 12:18
1

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.

triad
  • 20,407
  • 13
  • 45
  • 50