• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

host unresolved error!!

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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


 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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):



my 2 cents..
 
beta jane
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi thnx for a reply

my doubt is that,i have already set the proxy and port number in my emulator apn settings.Should
I do the same through my code too?





shoild i set mr port number in above line??

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
beta jane
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thnx!!

so how sholud i proceed!! Iam new to this whole technology and iam not aware as to how to use your code snippet in my code
Please help
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
beta jane
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnx....!!

the following is my HTTPRequestHelper class...
I dont have a device and hence iam left with no option other than the emulator.

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmmm...

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic