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
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
    
    1

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
    
    1

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: 41884
    
  63
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 - my free Android networking tools app
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
    
    1

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Connecting Internet from android code