It decodes stream from URLimageUrl = new URL(getQuestionImageUrl(questionNumber)); InputStream stream = imageUrl.openStream(); Bitmap bitmap = BitmapFactory.decodeStream(stream); image = new BitmapDrawable(getResources(), bitmap);
try { // Create a Drawable by decoding a stream from a remote URL imageUrl = new URL(getQuestionImageUrl(questionNumber)); InputStream stream = imageUrl.openStream(); Bitmap bitmap = BitmapFactory.decodeStream(stream); image = new BitmapDrawable(getResources(), bitmap); } catch (Exception e) { Log.e(DEBUG_TAG, "Decoding Bitmap stream failed"); image = getResources().getDrawable(R.drawable.noquestion); }
imageUrl = new URL(getQuestionImageUrl(questionNumber));InputStream stream = imageUrl.openStream(); Bitmap bitmap = BitmapFactory.decodeStream(stream); image = new BitmapDrawable(getResources(), bitmap);
Inistialize URL variable with the required link/url.Retreive the input stream of the URL.Create a bitmap by decoding the input stream.Convert it to a drawable image by using BitmapDrawable.try {imageUrl = new URL(getQuestionImageUrl(questionNumber));InputStream stream = imageUrl.openStream();Bitmap bitmap = BitmapFactory.decodeStream(stream);image = new BitmapDrawable(getResources(), bitmap);} catch (Exception e) {Log.e(DEBUG_TAG, "Decoding Bitmap stream failed");image = getResources().getDrawable(R.drawable.noquestion);}
First generate properrly configured URL object. Open and decode an input stream to URL into a Bitmap object. try {imageUrl = new URL(getquestionImageUrl(questionNumber) );InputStream stream = imageUrl.openStream();Bitmap bitmap = BitmapFactory.decodeStream(stream);image = new BitmapDrawable(getResourse(), bitmap);}catch (Exception e) {Log.e (DEBUg_TAG, "Decoding Bitmap stream failed");image = getResourse().getDrawable(R.drawable.noquestion);}
It decodes stream from URL
ReplyDeleteimageUrl = new URL(getQuestionImageUrl(questionNumber));
InputStream stream = imageUrl.openStream();
Bitmap bitmap = BitmapFactory.decodeStream(stream);
image = new BitmapDrawable(getResources(), bitmap);
try {
ReplyDelete// Create a Drawable by decoding a stream from a remote URL
imageUrl = new URL(getQuestionImageUrl(questionNumber));
InputStream stream = imageUrl.openStream();
Bitmap bitmap = BitmapFactory.decodeStream(stream);
image = new BitmapDrawable(getResources(), bitmap);
} catch (Exception e) {
Log.e(DEBUG_TAG, "Decoding Bitmap stream failed");
image = getResources().getDrawable(R.drawable.noquestion);
}
imageUrl = new URL(getQuestionImageUrl(questionNumber));
ReplyDeleteInputStream stream = imageUrl.openStream();
Bitmap bitmap = BitmapFactory.decodeStream(stream);
image = new BitmapDrawable(getResources(), bitmap);
Inistialize URL variable with the required link/url.
ReplyDeleteRetreive the input stream of the URL.
Create a bitmap by decoding the input stream.
Convert it to a drawable image by using BitmapDrawable.
try {
imageUrl = new URL(getQuestionImageUrl(questionNumber));
InputStream stream = imageUrl.openStream();
Bitmap bitmap = BitmapFactory.decodeStream(stream);
image = new BitmapDrawable(getResources(), bitmap);
} catch (Exception e) {
Log.e(DEBUG_TAG, "Decoding Bitmap stream failed");
image = getResources().getDrawable(R.drawable.noquestion);
}
First generate properrly configured URL object. Open and decode an input stream to URL into a Bitmap object.
ReplyDeletetry {
imageUrl = new URL(getquestionImageUrl(questionNumber) );
InputStream stream = imageUrl.openStream();
Bitmap bitmap = BitmapFactory.decodeStream(stream);
image = new BitmapDrawable(getResourse(), bitmap);
}
catch (Exception e) {
Log.e (DEBUg_TAG, "Decoding Bitmap stream failed");
image = getResourse().getDrawable(R.drawable.noquestion);
}