I've implemented a content provider for my imageview on a widget. I
had to do this because large bitmaps won't work with the normal
remoteview.setImageViewBitmap. Now I use
remoteview.setImageViewUri(id, "content://com.../image?widget="+id)
and it works great except one thing. Every time I redeploy the screen
goes black for a few moments than everything comes back. I've traced
it to: INFO/ActivityManager(52): Killing app android.process.acore
(pid 12451) because provider <myContentProvider> is in dying process
<myWidget>.
The only thing my custom provider implements is this:
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws
FileNotFoundException
{
int id =
Integer.valueOf(uri.getQueryParameter(PARAM_FILE_NAME));
Bitmap b = UpdateService.GetContainerBitmap(id);
String filename = "temp.png";
File dir = getContext().getCacheDir();
File file = new File(dir, filename);
try
{
FileOutputStream out = new FileOutputStream(file);
b.compress(Bitmap.CompressFormat.PNG, 100, out);
out.close();
}
catch(Exception e)
{
return null;
}
ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file,
ParcelFileDescriptor.MODE_READ_ONLY);
return new AssetFileDescriptor(pfd, 0,
AssetFileDescriptor.UNKNOWN_LENGTH);
}
Now if I take out the part where it returns the AssetFileDescriptor
then the crash doesn't happen. But of course the remoteview doesn't
update either. So I want to know has anyone seen this and does anyone
have a solution? Am I even doing everything correctly?
--
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