Search code examples
androidappwidgetprovider

Android AppWidgetProvider class not changing TextView


So I want to display the number of steps but this isn't working.

The widget loads but the TextView does not change!

public class WidgetDisplay extends AppWidgetProvider {

public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.dwidgitlayout);
    SharedPreferences load_steps = context.getSharedPreferences("steps", 0);
    int step_value = load_steps.getInt("steps", 0);
    views.setTextViewText(R.id.dwidgit_steps, String.valueOf(step_value));
    appWidgetManager.updateAppWidget(appWidgetIds, views);

}

}

Any ideas?


Solution

  • On what android version is that application is running? Because there is slight difference between 2.3 and 2.2 ..on 2.3 method onUpdate() isn't called at all.