Wednesday, April 23, 2014

android file download urlConn.getInputStream () throwing NUllPointerException


posts by wei542657623 on 2014-04-23 07:41:57 Edit
I hope that answers the great God to stay under the QQ and other contact information in case of problems encountered when convenient to ask.
Recently made an android software, you need to download files from the server. I am referring to mars video file to download, do first a little experiment. Do not know why urlConn.getInputStream () has been throwing NullPointerException. Here are some of the code used:
 
url = new URL (urlStr);
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection ();
buffer = new BufferedReader (new InputStreamReader (urlConn.getInputStream ())); / / Proven is urlConn.getInputStream () throw Exception

1, I've added AndroidManifest.xml file permissions:
 
<-! Required permission to use network functions ->









2, I'm on my phone's browser to access tomcat under urlStr specified file, so it should be no problem urlStr
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
There try catch you
Reply:
There
There I made yesterday in the following forum posts, you look in more detail.
Can not stay QQ ah, easy to contact
Reply:
cited a floor licai1210 reply:
have try catch you

There
There I made yesterday in the following forum posts, you look in more detail.
Can not stay QQ ah, easy to contact
Reply:
Where you put the http request, and is in the sub-thread it?

No comments:

Post a Comment