Update more widgets from BroadcastReceiver using RemoteViews

320 views Asked by At

I followed these steps: https://stackoverflow.com/a/18236800/824963 to make my broadcastreceiver work.

Actually all alarmmanagers are working fine, but each time onReceive is called all widget are updated with the same data

public class AlarmManagerBroadcastReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(final Context context, Intent intent)
    {       
        final String address = intent.getStringExtra("mykey");
        ...
        final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); 

        // downloading data
        ...
        // decoding data
        ...

        remoteViews.setTextViewText(R.id.mykey, newvalue);

        ComponentName thiswidget = new ComponentName(context, AppWidgetProvider.class);
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        appWidgetManager.updateAppWidget(thiswidget, remoteViews);
    }
}
0

There are 0 answers