Example usage for android.appwidget AppWidgetManager ACTION_APPWIDGET_BIND

List of usage examples for android.appwidget AppWidgetManager ACTION_APPWIDGET_BIND

Introduction

In this page you can find the example usage for android.appwidget AppWidgetManager ACTION_APPWIDGET_BIND.

Prototype

String ACTION_APPWIDGET_BIND

To view the source code for android.appwidget AppWidgetManager ACTION_APPWIDGET_BIND.

Click Source Link

Document

Activity action to launch from your AppWidgetHost activity when you want to bind an AppWidget to display and bindAppWidgetIdIfAllowed returns false.

Usage

From source file:com.appsimobile.appsii.module.home.appwidget.WidgetChooserActivity.java

@Override
public void onClick(View v) {
    int viewId = v.getId();
    if (viewId == R.id.ok_button) {
        if (mSelectedAppWidgetProviderInfo != null) {

            AppWidgetProviderInfo info = mSelectedAppWidgetProviderInfo;

            // In this case, we either need to start an activity to get permission to bind
            // the widget, or we need to start an activity to configure the widget, or both.
            mPendingAddWidgetId = mAppWidgetHost.allocateAppWidgetId();
            boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(mPendingAddWidgetId, info, null);
            if (success) {
                onAppWidgetSelected(mPendingAddWidgetId, info);
            } else {
                Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mPendingAddWidgetId);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.provider);

                mAppWidgetManager.getUser(mSelectedAppWidgetProviderInfo).addToIntent(intent,
                        AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
                // TODO: we need to make sure that this accounts for the options bundle.
                //                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS,
                // (Parcelable) null);
                startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
            }//www. j a  v a2 s  . co m
        }

    } else if (viewId == R.id.cancel) {
        finish();
    }
}

From source file:com.launcher.silverfish.HomeScreenFragment.java

private void loadWidget() {
    ComponentName cn = sqlHelper.getWidgetContentName();

    Log.d("Widget creation", "Loaded from db: " + cn.getClassName() + " - " + cn.getPackageName());
    // Check that there actually is a widget in the database
    if (cn.getPackageName().isEmpty() && cn.getClassName().isEmpty()) {
        Log.d("Widget creation", "DB was empty");
        return;//from  w w w  .j  ava2  s  .c  o m
    }
    Log.d("Widget creation", "DB was not empty");

    final List<AppWidgetProviderInfo> infos = mAppWidgetManager.getInstalledProviders();

    // Get AppWidgetProviderInfo
    AppWidgetProviderInfo appWidgetInfo = null;
    // Just in case you want to see all package and class names of installed widget providers,
    // this code is useful
    for (final AppWidgetProviderInfo info : infos) {
        Log.d("AD3", info.provider.getPackageName() + " / " + info.provider.getClassName());
    }
    // Iterate through all infos, trying to find the desired one
    for (final AppWidgetProviderInfo info : infos) {
        if (info.provider.getClassName().equals(cn.getClassName())
                && info.provider.getPackageName().equals(cn.getPackageName())) {
            // We found it!
            appWidgetInfo = info;
            break;
        }
    }
    if (appWidgetInfo == null) {
        Log.d("Widget creation", "app info was null");
        return; // Stop here
    }

    // Allocate the hosted widget id
    int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

    boolean allowed_to_bind = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn);

    // Ask the user to allow this app to have access to their widgets
    if (!allowed_to_bind) {
        Log.d("Widget creation", "asking for permission");
        Intent i = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
        Bundle args = new Bundle();
        args.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        args.putParcelable(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, cn);
        if (Build.VERSION.SDK_INT >= 21) {
            args.putParcelable(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE, null);
        }
        i.putExtras(args);
        startActivityForResult(i, REQUEST_BIND_APPWIDGET);
        return;
    } else {

        Log.d("Widget creation", "Allowed to bind");
        Log.d("Widget creation", "creating widget");
        //Intent i = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
        //createWidgetFromId(appWidgetId);
    }
    // Create the host view
    AppWidgetHostView hostView = mAppWidgetHost.createView(getActivity().getBaseContext(), appWidgetId,
            appWidgetInfo);

    // Set the desired widget
    hostView.setAppWidget(appWidgetId, appWidgetInfo);

    placeWidget(hostView);
}

From source file:com.launcher.silverfish.launcher.homescreen.HomeScreenFragment.java

private void loadWidget() {
    ComponentName cn = settings.getWidget();

    Log.d("Widget creation", "Loaded from db: " + cn.getClassName() + " - " + cn.getPackageName());
    // Check that there actually is a widget in the database
    if (cn.getPackageName().isEmpty() && cn.getClassName().isEmpty()) {
        Log.d("Widget creation", "DB was empty");
        return;/*from  w  w w .j a  va2s.  co  m*/
    }
    Log.d("Widget creation", "DB was not empty");

    final List<AppWidgetProviderInfo> infos = mAppWidgetManager.getInstalledProviders();

    // Get AppWidgetProviderInfo
    AppWidgetProviderInfo appWidgetInfo = null;
    // Just in case you want to see all package and class names of installed widget providers,
    // this code is useful
    for (final AppWidgetProviderInfo info : infos) {
        Log.d("AD3", info.provider.getPackageName() + " / " + info.provider.getClassName());
    }
    // Iterate through all infos, trying to find the desired one
    for (final AppWidgetProviderInfo info : infos) {
        if (info.provider.getClassName().equals(cn.getClassName())
                && info.provider.getPackageName().equals(cn.getPackageName())) {
            // We found it!
            appWidgetInfo = info;
            break;
        }
    }
    if (appWidgetInfo == null) {
        Log.d("Widget creation", "app info was null");
        return; // Stop here
    }

    // Allocate the hosted widget id
    int appWidgetId = mAppWidgetHost.allocateAppWidgetId();

    boolean allowed_to_bind = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn);

    // Ask the user to allow this app to have access to their widgets
    if (!allowed_to_bind) {
        Log.d("Widget creation", "asking for permission");
        Intent i = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
        Bundle args = new Bundle();
        args.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        args.putParcelable(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, cn);
        if (Build.VERSION.SDK_INT >= 21) {
            args.putParcelable(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE, null);
        }
        i.putExtras(args);
        startActivityForResult(i, REQUEST_BIND_APPWIDGET);
        return;
    } else {

        Log.d("Widget creation", "Allowed to bind");
        Log.d("Widget creation", "creating widget");
        //Intent i = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
        //createWidgetFromId(appWidgetId);
    }
    // Create the host view
    AppWidgetHostView hostView = mAppWidgetHost.createView(getActivity().getBaseContext(), appWidgetId,
            appWidgetInfo);

    // Set the desired widget
    hostView.setAppWidget(appWidgetId, appWidgetInfo);

    placeWidget(hostView);
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

/**
 * Process a widget drop.//from w  w w.  j  ava2  s. c  o  m
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param cell The cell it should be added to, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, int[] cell, int[] span, int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.android.launcher2.Launcher.java

/**
 * Process a widget drop./*from   w ww  .ja v  a  2 s. c  o m*/
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screen The screen where it should be added
 * @param cell The cell it should be added to, optional
 * @param position The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, int screen, int[] cell, int[] span,
        int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screen = info.screen = screen;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();

        if (!UiUtils.hasJellyBean()) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
            return;
        }
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        Bundle options = info.bindOptions;

        if (AppWidgetManagerCompat.bindAppWidgetIdIfAllowed(mAppWidgetManager, appWidgetId, info.componentName,
                options)) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java

/**
 * Process a widget drop./*from  ww  w . ja v  a  2 s.  com*/
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screen The screen where it should be added
 * @param cell The cell it should be added to, optional
 * @param position The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, int screen, int[] cell, int[] span,
        int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screen = info.screen = screen;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = false;
        if (options != null) {
            //TODO add options bundle for 4.2+
            success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.componentName);

            //                success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,
            //                        info.componentName, options);
        } else {
            success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.componentName);
        }
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.android.soma.Launcher.java

/**
 * Process a widget drop.//w w w.ja v a2s .  c  om
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 * @param position The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId, int[] cell, int[] span,
        int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = false;
        if (options != null) {
            success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.componentName, options);
        } else {
            success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.componentName);
        }
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

/**
 * Process a widget drop.//  w w  w  . j ava  2s .  c o  m
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId, int[] cell,
        int[] span) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = null;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:xyz.klinker.blur.launcher3.Launcher.java

/**
 * Process a widget drop.//from w ww.  ja  va  2 s . c om
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId, int[] cell,
        int[] span) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = null;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        if (LOGD) {
            Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
        }
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.android.launcher3.Launcher.java

/**
 * Process a widget drop./*from   ww  w .j ava 2s. c  o  m*/
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        if (LOGD) {
            Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
        }
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
        } else {
            setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, info.info, info));
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(info.info).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}