Tuesday, August 2, 2011

[android-developers] App Widget stops responding to input after all instances are removed and another added

I am having trouble when I add a one or more instances of my widget to the home screen, remove them all, then add another.

Here is the code I use to set the "onClick" intent for each button (button is a resource)

    protected void matchButtonToAction(Context context, RemoteViews views, String action, int button) {
        Intent intent = new Intent(context, MightyToggleWidget.class);
        intent.setAction(action);

        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
        views.setOnClickPendingIntent(button, pendingIntent);
    }

This only happens when I remove *ALL* instances and add one. If I add 2, remove 1 and add 1 it still works.

It is still receiving and reacting to events (such as wifi status changing or battery events).

Any ideas what could be causing this?
Thanks!
Ash

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment