相关疑难解决方法(0)

使用AlarmManager更新应用小部件

我试图比1.6docs施加的30分钟限制更频繁地更新Widget.在阅读了SO中的几乎所有帖子,以及开发人员文档和其他各种来源之后,我认为我已经达到了可以实现它的程度.所以,我尝试过,但失败了.从那时起,我已经搜索了更多的论坛和解决方案,我似乎无法更新它.

我有一个Update类来设置AlarmManager:

public class Update extends Service{

    @Override
    public void onStart(Intent intent, int startId) {
          String currentTemp = Battery.outputTemp;
          String currentLevel = Battery.outputLevel;
          String currentCard = Battery.outputCard;
          String currentInternal = Battery.memory;
          String currentRam = String.valueOf(Battery.outputRam).substring(0, 3) + "MB";

          // Change the text in the widget
          RemoteViews updateViews = new RemoteViews( 
          this.getPackageName(), R.layout.main);
          //update temp
          updateViews.setTextViewText(R.id.batteryTemp, currentTemp); 
          //update %
          updateViews.setTextViewText(R.id.batteryLevel, currentLevel);     
          //update level
          updateViews.setTextViewText(R.id.sdCard, currentCard);
          //update internal memory
          updateViews.setTextViewText(R.id.internal, currentInternal);
          //update ram
          updateViews.setTextViewText(R.id.ram, currentRam);

          ComponentName thisWidget = new ComponentName(this, Widget.class);
          AppWidgetManager …
Run Code Online (Sandbox Code Playgroud)

android android-widget alarmmanager

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

alarmmanager ×1

android ×1

android-widget ×1