예제 #1
0
 @SuppressLint("NewApi")
 @Override
 public void onAppWidgetOptionsChanged(
     final Context context, final AppWidgetManager manager, final int id, final Bundle options) {
   addView(manager, context, id, options);
   if (AppConstants.Versions.feature16Plus) {
     super.onAppWidgetOptionsChanged(context, manager, id, options);
   }
 }
  @Override
  public void onAppWidgetOptionsChanged(
      Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
    // Here you can update your widget view
    int minWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
    int maxWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH);
    int minHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
    int maxHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);
    Log.d(this.getClass().getSimpleName(), "resized");

    // Obtain appropriate widget and update it.
    appWidgetManager.updateAppWidget(appWidgetId, getRemoteViews(context, minWidth, minHeight));

    super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);

    this.updateAppWidget(context, appWidgetManager, appWidgetId);
  }