Hi iam using sdk 1.6,my browser works fine nd iam able to connect to all sites fromit.Iam behind proxy.
Iam not able to connect to gmail through my code,when i do it,i get host unresolved error.
I surfed regarding this error and found it to be something common,but none of the sites and blogs gave a solution to this problem.
I have given internet permissions in manifest file too.
The application basically tries to login to gmail with proper authentication and is supposed to fetch google contacts to emulator.
But iam not able to proceed further as i get this error please help me out!!
Any valuable suggestion welcome.
Thanks in advance
You get UnResolvedHost error because the client cannot connect to the remote machine. When you are sitting behind a proxy, you should set the proxy IP and port number in the class doing the transport. I have used DefaultHttpClient class for all of my GET and POST requests. This is how I set proxy(see if you can do something similar):
Setting the proxy in your APN settings will help you use your emulator Browser; I think, you will have to find a way to set proxy from your code.
BTW, the code snippet I posted, is for making proxy settings in the DefaultHttpClient class.
I notice you are using a custom class for doing the transport: import com.example.socapp.HTTPRequestHelper; You can try and find a way to make proxy settings in your HTTPRequestHelper class. Without knowing what this class is, I cant say much.
I generally use DefaultHttpClient class that comes with default android.jar to do my transport and the code snippet I posted in my reply above, configures the proxy for me.
Alternatives: 1. you can try to turn off the proxy and try your code
2. If you try your code on the actual device instead of emulator, and if the problem in your code is with the proxy settings alone, you can be assured that your code will work.
Your HttpRequestHelper class is using the DefaultHttpClient class. Here is what you can try:
copy the following setProxy() method in your HttpRequestHelper class.
Note: Replace the IP/port# with the IP/port# for your proxy. Also, give your username and password as argument to set credentials.
Call this setProxy() method from the performRequest() method of the HttpRequestHelper class specifically, below the line where you instantiate the DefaultHttpClient class:
That should set the proxy.
Hope that helps...
Note: you will have to comment out setProxy() when you are runnning your code on actual device or your transport wont work.