• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Android httpURLConnection

 
Greenhorn
Posts: 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
The Code below on execution in android throws IOException but not when executed as a java project.



This piece of code works fine when executed as a java project but not as an android project.. kindly reply soon
 
Ranch Hand
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the manifest, Have you added this node <uses-permission android:name="android.permission.INTERNET" /> in your manifest
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as @zoheb has corrected pointed out, missing <uses-permission android:name="android.permission.INTERNET" /> sounds like the culprit and is common

that said for others coming across this issue who have already added the INTERNET permission, another thing to check is to see if you are getting the NetworkOnMainThreadException

in @Martial's code snippet only MalforedURLException and IOException are being caught therefore would miss the NetworkOnMainThreadException if this snippet happened to be on the main thread (not suggesting it is in @Martial's case)

the idea is to safeguard the responsiveness of the main thread by disallowing network, for more info see here:

http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"lillinonahfirstname lillinonahlastname", please see your private messages regarding an important administrative matter.
 
I once met a man from Nantucket. He had a tiny ad
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic