Connecting internet in Android Emulator behind proxy

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Connecting internet in Android Emulator behind proxy

Postby satishfrnd » Fri Dec 11, 2009 2:48 pm

I'm new to develop an Android application to connect to internet from android emulator behind the proxy.

For that I added the proxy in "settings.db" through adb shell.

After that I can able to access internet through default browser in emulator.But from application i am not able to connect internet.

Thanks in advance.
satishfrnd
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Dec 11, 2009 2:01 pm

Top

Postby ashish » Fri Dec 18, 2009 5:53 pm

Is this thing working..in Android 1.6..

insert into system values('http_proxy',3232:8080');

I don't think so, I will do

settings-->wireless control->mobile network->access point name-->and set the proxy..

From the application I tried to use..

try
{
Settings.System.putString(getContentResolver(), Settings.System.HTTP_PROXY, "127.0.0.1:100"); //enable proxy



}catch (Exception ex){

}


But unable to insert in to DB, it always return false.


Please If somebody know the solution then please please help me..as I have already wasted 2 days behind the proxy.
ashish
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Fri Feb 20, 2009 8:09 am

Postby ashish » Fri Dec 18, 2009 9:44 pm

Hello friends finally I found a way...




DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(null,-1, null),
new UsernamePasswordCredentials("xxx","xxx"));




HttpHost httpproxy = new HttpHost("210.245.63.218",80,"http"); // your proxy //very IMP


httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,httpproxy); //very IMP


HttpPost httppost = new HttpPost(URL);

HttpResponse response = httpclient.execute(httppost);



HttpEntity entity = response.getEntity();
instream = entity.getContent();
ashish
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Fri Feb 20, 2009 8:09 am

Postby ashish » Fri Dec 18, 2009 9:46 pm

ashish
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Fri Feb 20, 2009 8:09 am

Postby ashish » Sat Dec 19, 2009 11:05 am

The solution which I posted is used whenever I am calling new URL.

but what if I am using webview in my application.Then in that case where to set the proxy..

I tried below one..but it's not working..

boolean status=Settings.System.putString(Set_Proxy.this.getContentResolver(), Settings.System.HTTP_PROXY,"189.80.88.114:8080");

status always return false..


Does ANYBODY know the solution how to set proxy globally..so that everywhere my app should use that proxy.

Thanks in advance...
ashish
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Fri Feb 20, 2009 8:09 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests