【问题标题】:Widgets sometimes don't work after reboot小部件有时在重新启动后不起作用
【发布时间】:2017-05-23 06:11:44
【问题描述】:

我所做的如下:

// prepare
mAppWidgetManager = AppWidgetManager.getInstance(applicationContent);
mAppWidgetHost = new LauncherAppWidgetHost(applicationContent, R.string.app_name);

// create widget
int appWidgetId = ...; // the id of the widget, that I have saved
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
AppWidgetHostView hostView = mAppWidgetHost.createView(context, appWidgetId, appWidgetInfo);
hostView.setAppWidget(appWidgetId, appWidgetInfo);

// show view
// now I just display the hostView

问题

一些设备一些小部件上,小部件在重启后会停止工作(widgetView 在重启后只是一个空视图)。任何想法为什么会发生这种情况?我已经要求我的用户在他们的家庭启动器中尝试相同的小部件,并且在重新启动后小部件也会继续工作......

【问题讨论】:

    标签: android widget android-widget


    【解决方案1】:

    我遇到了同样的问题,但我找到了另一种解决方法:在小部件的 XML 中,我添加了带有文本“小部件正在更新”的 textview,并在 Java 代码中以编程方式隐藏了这个 textview。因此,当您重新启动设备并且小部件仍未出现时,小部件上的此文本是摆脱这种情况的出路

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-02
      • 1970-01-01
      • 2014-01-22
      相关资源
      最近更新 更多