Thanks for the info, Lee.

That's quite a work around. I'm also a bit surprised that using a file
directly is more reliable than using a file from within the package.

More curiously, though, is why the file size is being reported
incorrectly at boot time. I wonder if it's also being reported
incorrectly at other times when the system might be extra busy -- such
as during an orientation change?

I've been going down a different route to try to resolve the issue --
but I haven't had a chance to touch the code in a few days to finish
it and see if it will even work. I'll update here if I figure anything
out.

Question: have you always been using PNG? The images I've been using
are JPEG.

Thanks for the info!



On Sep 5, 1:14 pm, Lee <[email protected]> wrote:
> Hello, problem solved here, though not elegantly.
>
> In case it helps, I discovered that at boot time the size of the
> bitmap file was only 104 bytes
> (and therefore probably other times it disappears). However, atwidget
> creation time the file
> is always perfect. So I cache the file atwidget-creation time and
> reuse it in every update after that.
>
> You could try similar to see if it solves your problem.
>
> Approximately:
>
> File filesDir = context.getFilesDir();
>
> String fileName  = getAppClassName().toLowerCase() + ".png";
>
> File cachePath = new File( filesDir, fileName );
>
> if ( ! cachePath.exists() ) {
>         Bitmap b = Utils.drawableToBitmap( draw );
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         b.compress( Bitmap.CompressFormat.PNG, 100, baos );
>         byte[] bitmapData = baos.toByteArray();
>
>         Utils.dataToDeviceFile(
>                 context, bitmapData, fileName, Activity.MODE_WORLD_READABLE
>         );
>
> }
>
> views.setImageViewUri( R.id.icon, Uri.parse( cachePath.toString() ) );
>
> (you should delete the cache file when thewidgetis deleted of
> course)
>
> Lee
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to