android.appwidget.AppWidgetProvider.onUpdate()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中android.appwidget.AppWidgetProvider.onUpdate()方法的一些代码示例,展示了AppWidgetProvider.onUpdate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppWidgetProvider.onUpdate()方法的具体详情如下:
包路径:android.appwidget.AppWidgetProvider
类名称:AppWidgetProvider
方法名:onUpdate

AppWidgetProvider.onUpdate介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onUpdate(Context context,
           AppWidgetManager appWidgetManager,
           int[] appWidgetIds) {
 super.onUpdate(context, appWidgetManager, appWidgetIds);
 for (int appWidgetId : appWidgetIds) {
  Bundle options=appWidgetManager.getAppWidgetOptions(appWidgetId);
  onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId,
               options);
 }
}

代码示例来源:origin: ankidroid/Anki-Android

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

    Timber.d("onUpdate");

    final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_add_note);
    final Intent intent = new Intent(context, NoteEditor.class);

    intent.putExtra(NoteEditor.EXTRA_CALLER, NoteEditor.CALLER_DECKPICKER);

    final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

    remoteViews.setOnClickPendingIntent(R.id.widget_add_note_button, pendingIntent);
    appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 public void onUpdate(Context ctxt, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {
  for (int i=0; i<appWidgetIds.length; i++) {
   Intent svcIntent=new Intent(ctxt, WidgetService.class);
   
   svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
   svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
   
   RemoteViews widget=new RemoteViews(ctxt.getPackageName(),
                     R.layout.widget);
   
   widget.setRemoteAdapter(R.id.words, svcIntent);

   Intent clickIntent=new Intent(ctxt, LoremActivity.class);
   PendingIntent clickPI=PendingIntent
               .getActivity(ctxt, 0,
                      clickIntent,
                      PendingIntent.FLAG_UPDATE_CURRENT);
   
   widget.setPendingIntentTemplate(R.id.words, clickPI);

   appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
  }
  
  super.onUpdate(ctxt, appWidgetManager, appWidgetIds);
 }
}

代码示例来源:origin: robolectric/robolectric

/**
 * Creates a bunch of widgets by inflating the same layout multiple times.
 *
 * @param appWidgetProviderClass the app widget provider class
 * @param widgetLayoutId         id of the layout to inflate
 * @param howManyToCreate        number of new widgets to create
 * @return the IDs of the new widgets
 */
public int[] createWidgets(Class<? extends AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId, int howManyToCreate) {
 AppWidgetProvider appWidgetProvider = ReflectionHelpers.callConstructor(appWidgetProviderClass);
 int[] newWidgetIds = new int[howManyToCreate];
 for (int i = 0; i < howManyToCreate; i++) {
  View widgetView = createWidgetView(widgetLayoutId);
  int myWidgetId = nextWidgetId++;
  widgetInfos.put(myWidgetId, new WidgetInfo(widgetView, widgetLayoutId, appWidgetProvider));
  newWidgetIds[i] = myWidgetId;
 }
 appWidgetProvider.onUpdate(context, realAppWidgetManager, newWidgetIds);
 return newWidgetIds;
}

代码示例来源:origin: ukanth/afwall

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
           int[] ints) {
  super.onUpdate(context, appWidgetManager, ints);
  final SharedPreferences prefs = context.getSharedPreferences(Api.PREF_FIREWALL_STATUS, 0);
  boolean enabled = prefs.getBoolean(Api.PREF_ENABLED, true);
  showWidget(context, appWidgetManager, ints, enabled);
}

代码示例来源:origin: ukanth/afwall

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
    int[] appWidgetIds) {
  super.onUpdate(context, appWidgetManager, appWidgetIds);
  RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.toggle_widget_layout);
  Intent configIntent = new Intent(context, ToggleWidgetActivity.class);
  PendingIntent configPendingIntent = PendingIntent.getActivity(context,0, configIntent, 0);
  remoteViews.setOnClickPendingIntent(R.id.toggle_widget_icon,configPendingIntent);
  appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
}

代码示例来源:origin: ukanth/afwall

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
           int[] appWidgetIds) {
  super.onUpdate(context, appWidgetManager, appWidgetIds);
  RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.toggle_widget_old_layout);
  Intent configIntent = new Intent(context, ToggleWidgetOldActivity.class);
  PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
  remoteViews.setOnClickPendingIntent(R.id.toggle_widget_icon_old, configPendingIntent);
  appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
}

代码示例来源:origin: dabutaizha/juzimi

/**
 * 每次窗口小部件被更新都调用一次该方法
 */
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  super.onUpdate(context, appWidgetManager, appWidgetIds);
  final int widgetSize = appWidgetIds.length;
  for (int i = 0; i < widgetSize; i++) {
    initSingleWidget(context, appWidgetManager, appWidgetIds[i]);
  }
}

代码示例来源:origin: xRoker/GHCWidget

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  if(this.appWidgetIds==null)
    this.appWidgetIds = appWidgetIds;
  updateWidget(context);
  super.onUpdate(context, appWidgetManager, appWidgetIds);
}

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

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

代码示例来源:origin: ybonnel/TransportsRennes

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  LOG_YBO.debug("onUpdate");
  context.startService(new Intent(UpdateTimeService.ACTION_UPDATE));
  super.onUpdate(context, appWidgetManager, appWidgetIds);
}

代码示例来源:origin: pranavpandey/dynamic-support

@Override
public void onUpdate(@NonNull Context context,
    @NonNull AppWidgetManager appWidgetManager, @NonNull int[] appWidgetIds) {
  super.onUpdate(context, appWidgetManager, appWidgetIds);
  for (int appWidgetId : appWidgetIds) {
    onAppWidgetOptionsChanged(context, appWidgetManager,
        appWidgetId, appWidgetManager.getAppWidgetOptions(appWidgetId));
  }
}

代码示例来源:origin: eswarm/DebugPurge

public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  // Perform this loop procedure for each App Widget that belongs to this provider
  for (int i=0; i<appWidgetIds.length; i++) {
    int appWidgetId = appWidgetIds[i];
    RemoteViews views = updateWidgetListView(context, appWidgetIds[i]);
    appWidgetManager.updateAppWidget(appWidgetId, views);
  }
  super.onUpdate(context, appWidgetManager, appWidgetIds);
}

代码示例来源:origin: grzegorznittner/chanu

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  for (int i = 0; i < appWidgetIds.length; i++)
    WidgetProviderUtils.update(context, appWidgetIds[i], getWidgetType());
  super.onUpdate(context, appWidgetManager, appWidgetIds);
}

相关文章