Example usage for android.appwidget AppWidgetManager ACTION_APPWIDGET_CONFIGURE

List of usage examples for android.appwidget AppWidgetManager ACTION_APPWIDGET_CONFIGURE

Introduction

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

Prototype

String ACTION_APPWIDGET_CONFIGURE

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

Click Source Link

Document

Sent when it is time to configure your AppWidget while it is being added to a host.

Usage

From source file:net.niyonkuru.koodroid.appwidget.WidgetConfigureActivity.java

@Override
public void onPause() {
    super.onPause();

    mAlertDialog.dismiss(); // avoid leaking window

    String action = getIntent().getAction();
    if (mResultCode == RESULT_CANCELED
            && (action != null && action.equals(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE))) {
        /* avoid phantom widgets */
        AppWidgetHost host = new AppWidgetHost(this, 1);
        host.deleteAppWidgetId(mAppWidgetId);
    } else {// w w  w .  j  a v a 2 s  .c  o m
        Intent intent = IntentUtils.createWidgetIntent(this, AppWidgetManager.ACTION_APPWIDGET_UPDATE);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { mAppWidgetId });

        sendBroadcast(intent);
    }
}

From source file:com.farmerbb.taskbar.activity.DashboardActivity.java

private void configureWidget(Intent data) {
    Bundle extras = data.getExtras();//from   w ww. java  2  s . c  om
    int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidgetInfo.configure != null) {
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);

        shouldFinish = false;
    } else {
        createWidget(data);
    }
}

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

private void configureWidget(Intent data) {
    // Get the selected widget information
    Bundle extras = data.getExtras();//from w  ww  . j a  v a  2  s .c  o  m
    int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidgetInfo.configure != null) {
        // If the widget wants to be configured then start its configuration activity
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
    } else {
        // Otherwise simply create it
        createWidget(data);
    }
}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public PendingIntent getWidgetPendingIntentForConfigurationActivity(final Context context,
        final int appWidgetId) {
    final Intent configureIntent = new Intent(context, WidgetPickConversationActivity.class);
    configureIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    configureIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
    configureIntent.setData(Uri.parse(configureIntent.toUri(Intent.URI_INTENT_SCHEME)));
    configureIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
    return getPendingIntentWithParentStack(context, configureIntent, 0);
}

From source file:de.spiritcroc.modular_remote.MainActivity.java

private void configureWidget(Intent data) {
    Bundle extras = data.getExtras();/*from w  ww  .  j  a  v a 2  s . c om*/
    int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidgetProviderInfo = appWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidgetProviderInfo.configure != null) {
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetProviderInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
    } else {
        createWidgetContainerFragment(data);
    }
}

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

void addAppWidgetImpl(final int appWidgetId, ItemInfo info, AppWidgetHostView boundWidget,
        AppWidgetProviderInfo appWidgetInfo) {
    if (appWidgetInfo.configure != null) {
        mPendingAddWidgetInfo = appWidgetInfo;

        // Launch over to configure widget, if needed
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
    } else {/*from  w ww. j a v a 2 s.  c  om*/
        // Otherwise just add it
        completeAddAppWidget(appWidgetId, info.container, info.screen, boundWidget, appWidgetInfo);
        // Exit spring loaded mode if necessary after adding the widget
        exitSpringLoadedDragModeDelayed(true, false, null);
    }
}

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

void addAppWidgetImpl(final int appWidgetId, ItemInfo info, AppWidgetHostView boundWidget,
        AppWidgetProviderInfo appWidgetInfo) {
    if (appWidgetInfo.configure != null) {
        mPendingAddWidgetInfo = appWidgetInfo;

        // Launch over to configure widget, if needed
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_APPWIDGET);
    } else {//w  w  w . ja va2  s  .c  o m
        // Otherwise just add it
        completeAddAppWidget(appWidgetId, info.container, info.screenId, boundWidget, appWidgetInfo);
        // Exit spring loaded mode if necessary after adding the widget
        exitSpringLoadedDragModeDelayed(true, false, null);
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void configureOrAddAppWidget(Intent data) {
    int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidget = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidget.configure != null) {
        // Launch over to configure widget, if needed
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidget.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

        startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
    } else {// w  w w.ja v a 2s. c  om
        // Otherwise just add it
        onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
    }
}