android下载文件的问题
private InputStream getInputStreamFromUrl(String urlStr) throws IOException {
URL url = null;
url = new URL(urlStr);
HttpURLConnection urlConnection = null;
urlConnection = (HttpURLConnection)url.openConnection();
InputStream inputStream = urlConnection.getInputStream();//这一行返回值总是为空
return inputStream;
}
我在模拟器上添加一个下载按钮,用来下载mp3文件,可是在上面的代码中inputStream 总是为空,为什么?