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, at widget
creation time the file
is always perfect. So I cache the file at widget-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 the widget is 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