I have tried to get the bitmap image from the path of the image. But BitmapFactory.decodeStream returns null value.
Code:
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
connection.disconnect();
input.close();
I have searched in more sites, still i did not get the solution.
Got a Solution :
The problem was that once you’ve used an
InputStreamfrom aHttpUrlConnection, you can’t rewind and use the sameInputStreamagain. Therefore you have to create a newInputStreamfor the actual sampling of the image. Otherwise we have to abort theHTTPrequest.