XGouchet
XGouchet

Reputation: 10203

AnimationDrawable in an AppWidget

I've been trying to add an AnimationDrawable in one of my app widgets. I create an xml resource file looking like this. It displays images of a led with the light on and off (so the animation is a blinking led).

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" >
    <item
        android:drawable="@drawable/time_circuits_led_on"
        android:duration="500"/>
    <item
        android:drawable="@drawable/time_circuits_led_off"
        android:duration="500"/>

</animation-list> 

When I installed my AppWidget on my phone, I saw no animation and after some research found that you can't animate drawable in an app widget.

I unlocked my phone a couple of minutes later, and the led was blinking, meaning the animation was working. Nowhere in my AppWidgetProvider do I call the AnimationDrawable#start() method, and so it should'nt be blinking, yet it is.

I locked and unlocked it again severall times, and sometimes the led blinks, sometimes it doesn't. If it blinks (sometimes) maybe there is something I can do to make sure it always blinks.

I'm running this on a Galaxy Nexus, running Android 4.1.1. I also tested this on a phone on Android 2.3.3 and the led never blinks.

Upvotes: 0

Views: 1050

Answers (1)

Yulia Rogovaya
Yulia Rogovaya

Reputation: 934

I think the way to accomplish what you're trying to do is use a ViewFlipper, it is supported in RemoteViews. Though, in terms of battery use that doesn't look right.

Upvotes: 1

Related Questions