• 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:

AsyncTask() failing on HttpsURLConnection.getOutputStream()

 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still fumbling through Android, today, in trying to create an AsyncTask to connect to a website, post some data, and get a response. My understanding is that i must use an AsyncTask here, as the main thread is not allowed to do this sort of work. And, iiuc, AsyncTask threads are not available for debugging with the Studio debugger.

The log shows "1" then "exception," as it fails on connection.getOutputStream(). I have verified it is that specific method by splitting up the statement, and setting connection.getOutputStream() to an interim variable in it's own line of code.

How to determine what the error is?
 
Bartender
Posts: 7488
171
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the full stack trace.
 
Brian Tkatch
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why didn't i think of that? I feel kind of silly now. I had forgotten to remove my filter, thus i never saw when it said: java.lang.SecurityException: Permission denied (missing INTERNET permission?)

I did have the following line in AndroidManifest.xml: <uses-permission android:name="INTERNET"/>
But, a simple search found that should have been: <uses-permission android:name="android.permission.INTERNET"/>

It also says i need i also needed: <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>, but we'll wait and see on that one. Right now i have a different bug to work out.

Thank you!

 
CAUTION! Do not touch the blades on your neck propeller while they are active. 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