相关疑难解决方法(0)

使用集合更新app小部件的问题

我使用我的应用程序的集合创建了一个应用程序小部件,该小部件显示该特定日期的日期和项目列表.一切正常,窗口小部件正在根据需要进行更新.但有时,通过单击下一个和上一个按钮更改窗口小部件中的日期时会发生什么,列表不刷新意味着项目在该特定日期未更新.此行为是随机的,有时仅发生.那么为什么会发生这种情况,我的代码中有任何错

我使用的代码是:

WidgetProvider.class

public class WidgetProvider extends AppWidgetProvider 
{   
    private ThemeManager    m_ThemeManagerObject;

    private static String   WIDGET_NEXT_BUTTON = "in.test.widgetApp.WIDGET_NEXT_BUTTON";

    private static String   WIDGET_PREV_BUTTON = "in.test.widgetApp.WIDGET_PREV_BUTTON";    

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) 
    {               
        super.onUpdate(context, appWidgetManager, appWidgetIds);

        // Set Date to current Date
        NoteManager.getSingletonObject().setWidgetToCurrentDate();

        // Code to update the widget by current date 
        updateAppWidget(context, AppWidgetManager.getInstance(context), appWidgetIds);
    }   

    @Override
    public void onReceive(Context context, Intent intent) 
    {           
        super.onReceive(context, intent);

        int numOfDays = 1;

        ComponentName thisWidget = new ComponentName(context, WidgetProvider.class);
        AppWidgetManager appWidgetManager = …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-appwidget

9
推荐指数
1
解决办法
5117
查看次数