Tuesday, August 28, 2012

UnknownHostException - Connection to the internet problem

If you are trying to connect to the internet using one of Android's HTTP Clients, but when you do so in your code you get java.net.UnknownHostException, it means your application doesn't have the permission to connect to the internet. To resolve it, add the INTERNET permission to your application's AndroidManifest.xml file. Follow these steps if you are using Eclipse:

  1. Open your AndroidManifest.xml
  2. Click on the Permission tab
  3. Click on Add... then choose "Uses Permission"
  4. From the list of permissions choose "android.permission.INTERNET"
  5. Save and re-run your application

No comments:

Post a Comment