aspose file tools*
The moose likes Android and the fly likes Connecting Internet from android code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Connecting Internet from android code" Watch "Connecting Internet from android code" New topic
Author

Connecting Internet from android code

rashmi swamy
Greenhorn

Joined: Oct 05, 2010
Posts: 14
Hi,
I am only able to connect internet through emulator browser. I am not able to connect to Internet through application code even after setting proxy in emulator and also inserting values to system table. It is throwing unknown host exception. I tried with one more option that setting proxy in application Run Configuration. But it is throwing Authentication scheme ntlm not supported error. I have given Internet permission in manifest also. Please let me know some solution for connecting Internet through code.

Thanks & Regards,
Rashmi
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369

Which version of SDK are you using?


[List of FAQs] | [Android FAQ] | [Samuh Varta]
rashmi swamy
Greenhorn

Joined: Oct 05, 2010
Posts: 14
android SDK 2.2
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369

For 2.2, you don't have to explicitly setup proxy in the emulator(i.e. you wont have to change an entry in the System table, nor start with -proxy switch, neither would you have to create additional APNs).

In your java code, if you are running from behind a proxy just add your credentials to the HttpClient instance.

Something like:

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
The 2.2 emulator has an issue with networking that most real devices don't have (namely, it doesn't support IP6). Try a 2.1 emulator or an actual 2.2 device.


Ping & DNS - updated with new look and Ping home screen widget
rashmi swamy
Greenhorn

Joined: Oct 05, 2010
Posts: 14
Thankyou Monu.
I have put your code in my activity class and trying load www.google.com through web view. But it is not working. Please give me some solution.
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369

Ulf Dittmer wrote:The 2.2 emulator has an issue with networking that most real devices don't have (namely, it doesn't support IP6). Try a 2.1 emulator or an actual 2.2 device.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Connecting Internet from android code
 
Similar Threads
Https post, through Proxy settings
socket communication between mobile browser and proxy server
Internet is not running on emulator
Unresolved Host Exception
How to connect to the internet behind proxy ?