wood burning stoves 2.0*
The moose likes Android and the fly likes How to connect to the internet behind proxy ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to connect to the internet behind proxy ?" Watch "How to connect to the internet behind proxy ?" New topic
Author

How to connect to the internet behind proxy ?

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197
Hi All,

Not recently I installed the android SDK for the first time. After
playing with the emulator I notice that I can’t log in to the internet
via the browser application.
I looked for a and found the following command : “emulator -avd em15 -
http-proxy <proxy>”

For the <proxy> I copy the prams’ from the browser (Tools  Internet
Option  Connection  Lan settings ) but still I can’t see any
WebPages via the browser.

Any suggestion ?

Thanks
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

Configuring Android emulator for proxy:

In the earlier versions of Android emulators (up to version 1.1r2), you were required to make an entry in the system table of “com.android.provider.setting.db” database and/or start the emulator with –http-proxy switch supplying it the ip address and port number of your proxy.

These methods however, have become obsolete and don’t work with SDKv1.5.
Step 1: On emulator, go to:
Home->Menu->Settings->WirelessControls->MobileNetworks->Access Point Names->T-mobile US->set Proxy Ip and Port#

Step 2: Now the next time you go to a web address, the browser will prompt for your user-id and password. Enter your credentials and you should be good to go.

Reference: http://groups.google.com/group/android-beginners/browse_thread/thread/069fbb8c7465de38/5ced4f948c4ed622#5ced4f948c4ed622" target="_new" rel="nofollow">


[List of FAQs] | [Android FAQ] | [Samuh Varta]
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197
thanks

working nice
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

you're welcome!
VineetK Singh
Ranch Hand

Joined: Jun 02, 2009
Posts: 47
Hi Monu

I am also facing the same problem. I tried using the method mentioned in your post. I have entered the proxy and port information in the APN section, but my emulator doesn't seem to connect to the internet. All I get is a page saying that proxy authetication required.

I tried adding the user name and password , that I use to connect to the network, in the APN field, but still it doesn't seem to work. Interestingly, as mentioned in your post, the browser never prompts me for the autentication details, whether I enter the details(in APN section) or not.


Is there something I am missing out, or any other way out of this??


Thanks in advance.


Copy Paste is a design error!!
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

Do not enter a user name or password on the "edit access point" page and see if the browser asks you for username/password. If it does, enter your username by prepending it with your domain name like:
"<your-domain-name>\<your-user-name>".

If it does not prompt for your credentials then you would have to continue googling and post the answer here if and when you find it!
vina parmar
Greenhorn

Joined: Nov 09, 2009
Posts: 22
Hi Monu,
I am using SDK 2.0. I am facing same prolem.
I have set all the parameter which you have mentioned.

1. Now when I open the browser it will not prompt and it will show me the page.
2. And if I set the username and Password then also it not prompts but again showing me page.

I am developing an application which send the data to server and get the response in JSON.
The code is below:


This will give me error as : java.net.SocketException: Permission denied (maybe missing INTERNET permission)

What setting I am missing?
Is your method working in SDK 2.0?
Check my URL is right coz some one writes the ip:port before that which also not working.

Waiting of your reply.
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

Yours is just a case of missing Permission in the manifest file, as the logs have pointed out.
You will have to add a <uses-permission> in your manifest file(android.permission.INTERNET).
vina parmar
Greenhorn

Joined: Nov 09, 2009
Posts: 22
Thanks Monu,
It's working fine.


Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

you are welcome... "Mobile Developer"
Why don't you change your display name to something that is more addressable? You know we have a Naming Policy here on the Ranch.
aye thwe
Greenhorn

Joined: Jul 09, 2010
Posts: 4
Hi Monu,
I m a newbie to android too and i found that exception too.
In my manifest i already put <uses-permission>, but still have this exception.
here is my create Feed method
(that's from Newsdroid tutorial..)

public void createFeed(Context ctx,String linktext) throws ParserConfigurationException, SAXException, IOException
{
targetFlag = TARGET_FEED;

try {

URL url = new URL(linktext.toString());
droidDB = new NewsDroidDB(ctx);
droidDB.open();

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
RSSHandler myExampleHandler = new RSSHandler();
xr.setContentHandler(myExampleHandler);
InputStream mystream = null;
try{
mystream = url.openStream();
}catch (Exception e)
{
Log.e("RSS Handler", e.toString());
}
InputSource is = new InputSource(mystream);

try {
xr.parse(is);
} catch (SAXException e) {
e.printStackTrace();

Log.e("xr.pasrse(is)", e.toString());
}

} catch (Exception e) {

Log.e("RSS Handler", e.toString());
}


}
rashmi swamy
Greenhorn

Joined: Oct 05, 2010
Posts: 14
Hi Monu,
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
Dan Zu
Greenhorn

Joined: Nov 24, 2010
Posts: 1
rashmi swamy wrote:Hi Monu,
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


I have the same problem.

I've found that there's a method in the DefaultHttpClient variables called setProxyAuthenticationHandler(AuthenticationHandler proxyAuthHandler) but I have no Idea how to configurate the proxyAuthHandler variable.

Anybody could help on this?

Thanks
Raj Bhatia
Greenhorn

Joined: Mar 30, 2011
Posts: 1
Hi All,

I am unable to find/activate the proxy (server and port) settings for my Wi-fi network. I have an HTC Wildfire with android 2.2. I am able to access internet on proxy via Opera browser by entering the required setting there, but still the wifi internet access is not global to my device.

Additionally, the java application I use via the java android app is unable to access internet even from the Mobile data network. Please advise.

I am not sure if this is the right forum to post this. If so, then i request you to direct me to the right source of solution.

Thanks!

-RB

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to connect to the internet behind proxy ?