android.appwidget.AppWidgetHost.allocateAppWidgetId()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(141)

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

AppWidgetHost.allocateAppWidgetId介绍

暂无

代码示例

代码示例来源:origin: Neamar/KISS

boolean onOptionsItemSelected(MenuItem item) {
  if (item.getItemId() == R.id.widget) {
    if (!widgetUsed) {
      // request widget picker, a selection will lead to a call of onActivityResult
      int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
      Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
      pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      mainActivity.startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET);
    } else {
      // if we already have a widget we remove it
      removeAllWidgets();
    }
    return true;
  }
  return false;
}

代码示例来源:origin: quaap/LaunchTime

@Override
public int allocateAppWidgetId() {
  int appid = super.allocateAppWidgetId();
  //mAppIds.add(appid);
  return appid;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

private boolean addAppWidget(SQLiteDatabase db, ContentValues values, ComponentName cn,
    Bundle extras) {
  boolean allocatedAppWidgets = false;
  final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
  try {
    int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
    values.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);
    values.put(Favorites.APPWIDGET_ID, appWidgetId);
    values.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
    values.put(Favorites._ID, generateNewItemId());
    dbInsertAndCheck(this, db, TABLE_FAVORITES, null, values);
    allocatedAppWidgets = true;
    // TODO: need to check return value
    appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn);
    // Send a broadcast to configure the widget
    if (extras != null && !extras.isEmpty()) {
      Intent intent = new Intent(ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE);
      intent.setComponent(cn);
      intent.putExtras(extras);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      mContext.sendBroadcast(intent);
    }
  } catch (RuntimeException ex) {
    Log.e(TAG, "Problem allocating appWidgetId", ex);
  }
  return allocatedAppWidgets;
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

代码示例来源:origin: clemensbartz/essential-launcher

/**
 * Bind a widget for a provider.
 * @param provider the provider component
 * @param configure the configure component
 */
public void bindWidget(final ComponentName provider, final ComponentName configure) {
  final int appWidgetId = appWidgetHost.allocateAppWidgetId();
  if (appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, provider)) {
    // Binding is allowed, go straight to configuring
    configureWidget(appWidgetId, configure);
  } else {
    // Ask for permission
    widgetConfigure = configure;
    final Intent intent = IntentUtil.createWidgetBindIntent(provider, appWidgetId);
    final Bundle options = new Bundle();
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN);
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, frWidget.getMinimumWidth());
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, frWidget.getWidth());
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, frWidget.getMinimumHeight());
    options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, frWidget.getHeight());
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
    startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
  }
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

long insertedId = -1;
try {
  int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

代码示例来源:origin: klinker24/launcher3

long insertedId = -1;
try {
  int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

代码示例来源:origin: WeAreFairphone/FP2-Launcher

long insertedId = -1;
try {
  int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

代码示例来源:origin: enricocid/LaunchEnr

long insertedId = -1;
try {
  int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

代码示例来源:origin: MoMoWait/LeanbackLauncher

options.putInt("appWidgetMinHeight", height);
options.putInt("appWidgetMaxHeight", height);
appWidgetId = this.mAppWidgetHost.allocateAppWidgetId();
z = this.mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, appWidgetInfo.provider, options);

代码示例来源:origin: fookwood/Launcher3

long insertedId = -1;
try {
  int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

代码示例来源:origin: rockon999/LeanbackLauncher

options.putInt("appWidgetMinHeight", height);
options.putInt("appWidgetMaxHeight", height);
appWidgetId = this.mAppWidgetHost.allocateAppWidgetId();
success = this.mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, appWidgetInfo.provider, options);

代码示例来源:origin: WeAreFairphone/FP2-Launcher

int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {

代码示例来源:origin: fookwood/Launcher3

int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {

代码示例来源:origin: enricocid/LaunchEnr

/**
 * Called when place-automatically button is clicked.
 */
public void onPlaceAutomaticallyClick(View v) {
  if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
    InstallShortcutReceiver.queueShortcut(
        new ShortcutInfoCompat(mRequest.getShortcutInfo()), this);
    mRequest.accept();
    finish();
    return;
  }
  mPendingBindWidgetId = mAppWidgetHost.allocateAppWidgetId();
  boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
      mPendingBindWidgetId, mRequest.getAppWidgetProviderInfo(this), mWidgetOptions);
  if (success) {
    acceptWidget(mPendingBindWidgetId);
    return;
  }
  // request bind widget
  Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
  intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mPendingBindWidgetId);
  intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER,
      mPendingWidgetInfo.componentName);
  intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE,
      mRequest.getAppWidgetProviderInfo(this).getProfile());
  startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

try {
  int appWidgetId = new AppWidgetHost(getContext(), Launcher.APPWIDGET_HOST_ID)
      .allocateAppWidgetId();
  values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
  if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {

代码示例来源:origin: klinker24/launcher3

try {
  int appWidgetId = new AppWidgetHost(getContext(), Launcher.APPWIDGET_HOST_ID)
      .allocateAppWidgetId();
  values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
  if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {

代码示例来源:origin: enricocid/LaunchEnr

try {
  AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
  int appWidgetId = widgetHost.allocateAppWidgetId();
  values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
  if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {

相关文章