On Tue, Jun 22, 2010 at 3:17 AM, James W <[email protected]> wrote: > You can have animations in App widgets.
For some definition of "animation", yes. My apologies to the OP. When I see "animated", my mind immediately jumps to android.view.animation, which is not possible with an app widget. > For Ryan's particular example, using the Alarm Manager with a > recurring alarm every second that calls OnUpdate() or some other > routine which updates the view would do the job. > > Then in the updating routine, you just change the bitmap on an > ImageView which is part of your appwidgets layout. > > You can certainly load a bitmap from resources or an external file and > update your imageview with that, but the bit I am not sure about is > whether you could create a bitmap on the fly and draw to it instead of > a Canvas, then load that into your imageview. You can set setImageViewBitmap() to take a drawn Bitmap and send it over to the app widget. However, on a once-per-second clip, I worry not only about battery life, but CPU impact on other applications (e.g., real-time games). Be sure to set your thread priority as low as it goes. And if you do not need to draw the images, but rather can just use canned resources (e.g., clock with only 10 digits, battery monitor with only 100 levels), that is probably faster than drawing it yourself. Anything you can do to minimize the work done per cycle would be greatly beneficial. Also, please let the user configure the period, or disable the animation, or something. http://www.androidguys.com/2010/03/29/code-pollution-background-control/ Finally, bear in mind that app widgets used to have no minimum update period when using android:updatePeriodMillis. Now, that minimum period is 30 minutes. As James W notes, you can bypass that with your own alarms. However, there is probably a reason *why* the minimum period was raised to 30 minutes. I worry about the impacts of any app widget that tries to massively overshoot that frequency, and an 1800:1 ratio would constitute "massively overshoot". -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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

