how to implement tween animation with AppWidget using RemoteViews?

by shleeforandroid » Thu, 30 Apr 2009 17:17:52 GMT

Sponsored Links
 i, guys

I'm testing AppWidget to play animation on the homescreen.

This is my testing source using Service and RemoteViews.

I confirmed the modification of the image of layout's ImageView.

I thought it possible to implement the animation using RemoteViews or
AppWidgetHostView ...
But I failed. I didn't see any change of the image.

How to adapt the animation to RemoteViews?

I tried like this.

Some Imports
import android.appwidget.AppWidgetHostView;

public class TestAnimationWidget extends AppWidgetProvider {

public void onReceive(Context context, Intent intent) {

// TODO Auto-generated method stub
String action = intent.getAction();
Bundle extras = intent.getExtras();
if (extras != null) {
int[] appWidgetIds = extras.getIntArray
if (appWidgetIds != null && appWidgetIds.length > 0) {
this.onUpdate(context, AppWidgetManager.getInstance(context),
else if(AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)){
Bundle extras = intent.getExtras();
if (extras != null) {
int[] appWidgetIds = extras.getIntArray
if (appWidgetIds != null && appWidgetIds.length > 0) {
this.onDeleted(context, appWidgetIds);
else if(AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)){
else if(AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)){

public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[ ] appWidgetIds) {
// TODO Auto-generated method stub
context.startService(new Intent
super.onUpdate(context, appWidgetManager, appWidgetIds);

public static class UpdateServiceAnimation extends Service {
private SensingMovement mSensingMove;
private AppWidgetManager mAppWidgetManager;
public AppWidgetProviderInfo mAWPInfo;
private AppWidgetHost mAppWidgetHost;
private List<AppWidgetHostView> mAppWidgetHostViewList;
public static int HOSTID = 0;
static public int count = 0;

int[] mAnim_img_IDs = new int[]{
R.drawable.gallery_photo_1, R.drawable.gallery_photo_2,
R.drawable.gallery_photo_3, R.drawable.gallery_photo_4

public void onCreate() {
mSensingMove = new SensingMovement(this);
mAppWidgetHost = new AppWidgetHost(this,HOSTID);
mAppWidgetManager = AppWidgetManager.getInstance(this);
mAppWidgetHostViewList = new ArrayList<AppWidgetHostView>();
int[ ] appWidgetIds = mAppWidgetManager.getAppWidgetIds(new

for(int i = 0 ; i < appWidgetIds.length ; i++){
mAWPInfo =
appWidgetIds[i], mAWPInfo));

// TODO Auto-generated method stub

Other Threads

1. Updating device time

How to update the Device time via the application? Is there any APIs
available for this?


2. expanding space for apps in sd card


I'm studying app2sd solution to expand space for apps using sd card.
I think the use of a looped ext2 img file is more easy to handle by
scripts to be used in softwares like htc sync (or any sync) however i
think triggering an sd scan seeking for extra ext2 partition or an
ext2 img file on the sd card could be a nice way to a further option
in the android preferences: which is "select a different partition to
store your apps"


3. Select/Highlight/Focus on Text in a WebView

4. Android Market Problems...

5. Mobile & Embedded Industry Expert Opinions Needed

6. Looking for a developer to give a student talk on Android Development

7. Upload to My Maps user account