android.appwidget.AppWidgetProvider类的使用及代码示例

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

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

AppWidgetProvider介绍

暂无

代码示例

代码示例来源:origin: naman14/Timber

@Override
public void onReceive(Context context, Intent intent) {
  String action = intent.getAction();
  if (action != null && action.startsWith("com.naman14.timber.")) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    ComponentName thisAppWidget = new ComponentName(context.getPackageName(), this.getClass().getName());
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);
    onUpdate(context, appWidgetManager, appWidgetIds, intent.getExtras());
  } else {
    super.onReceive(context, intent);
  }
}

代码示例来源: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: aa112901/remusic

public void onDisabled(Context context) {
  Log.e(TAG,"ondisable = " + isInUse);
  super.onDisabled(context);
  isInUse = false;
  Log.e(TAG,"ondisable = " + isInUse);
}

代码示例来源:origin: aa112901/remusic

public void onEnabled(Context context) {
  Log.e(TAG,"onenabled = " + isInUse);
  super.onEnabled(context);
  isInUse = true;
  Log.e(TAG,"onenabled = " + isInUse);
}
//当最后一个该Widget删除是调用该方法,注意是最后一个

代码示例来源:origin: aa112901/remusic

@Override
public void onDeleted(Context context, int[] appWidgetIds) {
  super.onDeleted(context, appWidgetIds);
  albumMap.clear();
}

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

/**
 * 当小部件大小改变时
 */
@Override
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
  super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
}

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

@Override
public void onEnabled(Context context) {
  super.onEnabled(context);
  UsageAnalytics.sendAnalyticsEvent(this.getClass().getSimpleName(), "enabled");
}

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

/**
 * 每删除一次窗口小部件就调用一次
 */
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
  super.onDeleted(context, appWidgetIds);
}

代码示例来源:origin: AdleyLong/RecyclerViewDemo

/**
 * 当 Widget 第一次被添加或者大小发生变化时调用该方法,可以在此控制 Widget 元素的显示和隐藏。
 *
 * @param context
 * @param appWidgetManager
 * @param appWidgetId
 * @param newOptions
 */
@Override
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
  super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
}

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

@Override
public void onReceive(Context context, Intent intent) {
 if (intent.getAction() == null) {
  updateWidget(context,
         AppWidgetManager.getInstance(context),
         intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                  -1));
 }
 else {
  super.onReceive(context, intent);
 }
}

代码示例来源: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: ankidroid/Anki-Android

@Override
public void onDisabled(Context context) {
  super.onDisabled(context);
  Timber.d("SmallWidget: Widget disabled");
  SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(context);
  preferences.edit().putBoolean("widgetSmallEnabled", false).commit();
  UsageAnalytics.sendAnalyticsEvent(this.getClass().getSimpleName(), "disabled");
}

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

@Override
public void onDisabled(Context context) {
  super.onEnabled(context);
  UsageAnalytics.sendAnalyticsEvent(this.getClass().getSimpleName(), "disabled");
}

代码示例来源:origin: TUM-Dev/Campus-Android

@Override
public void onDeleted(Context context, int[] appWidgetIds) {
  // When the user deletes the widget, delete the associated setting from the database.
  super.onDeleted(context, appWidgetIds);
}

代码示例来源:origin: Theoneee/DynamicWallpaper

@Override
public void onAppWidgetOptionsChanged(Context context,
                   AppWidgetManager appWidgetManager, int appWidgetId,
                   Bundle newOptions) {
  Log.e(TAG, "onAppWidgetOptionsChanged");
  super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId,
      newOptions);
}

代码示例来源:origin: k9mail/k-9

@Override
public void onReceive(Context context, Intent intent) {
  super.onReceive(context, intent);
  String action = intent.getAction();
  if (action.equals(ACTION_UPDATE_MESSAGE_LIST)) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.listView);
  }
}

代码示例来源: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: dabutaizha/juzimi

/**
 * 当最后一个该窗口小部件删除时调用该方法
 */
@Override
public void onDisabled(Context context) {
  super.onDisabled(context);
}

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

@Override
public void onEnabled(Context context) {
  super.onEnabled(context);
  Timber.d("SmallWidget: Widget enabled");
  SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(context);
  preferences.edit().putBoolean("widgetSmallEnabled", true).commit();
  UsageAnalytics.sendAnalyticsEvent(this.getClass().getSimpleName(), "enabled");
}

代码示例来源:origin: byhieg/easyweather

@Override
public void onDeleted(Context context, int[] appWidgetIds) {
  // 当 widget 被删除时,对应的删除set中保存的widget的id
  for (int appWidgetId : appWidgetIds) {
    idsSet.remove(Integer.valueOf(appWidgetId));
  }
  super.onDeleted(context, appWidgetIds);
}

相关文章