Hello everybody,
I'm programming an appwidget that downloads an image from a website
and displays it. The approach is easy, but I get an error, if I want
to set the imageView to the URI of the downloaded image.
First I set the imageView with updateViews.setImageViewBitmap, where
updateViews is a RemoteViews Object. The Problem was an Transaction
Binding Error, because the images gets serialized and the transaction
became to big. So good so far. Then I decided I want to save the
picture on the ! internal ! (not external / not sd-card) memory. The
download works fine and in my preferences activity of the appwidget
the downloaded image gets displayed. But, when I go back from the
preferences activity then the Widget doesn't show the image.
The error occurs is: INFO/System.out(151): resolveUri failed on bad
bitmap uri: /data/data/com.mywidget/files/temp.jpg
But the preference activity can display the image with exactly this
URI!
So where is the problem, I really can't find it!
This is the part where I create my UpdateViews. This gets called by
the UpdateService!
String filename = "temp.jpg";
context.deleteFile(filename);
FileOutputStream fos;
File file = context.getFileStreamPath(filename);
Log.d(TAG, "BuildUpdate: "+file.toString());
try {
Bitmap bmImg =
BitmapFactory.decodeByteArray(data, 0,
data.length); //options am Ende einfügen
fos = context.openFileOutput(filename,
Context.MODE_PRIVATE);
BufferedOutputStream bos = new
BufferedOutputStream(fos);
bmImg.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
fos.close();
} catch (FileNotFoundException e) {
Log.d(TAG, e.toString());
e.printStackTrace();
} catch (IOException e) {
Log.d(TAG, e.toString());
e.printStackTrace();
}
updateViews.setImageViewUri(R.id.ImageView01,
Uri.parse(file.toString()));
I hope someone can help me with this error.
Thanks a lot,
Christian
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en