Code example for AppWidgetHost

Methods: deleteAppWidgetId

0
    int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
 
    String customWidget = data.getStringExtra("custom_widget");
    if ("search_widget".equals(customWidget)) {//user picked the extra
        // We don't need this any more, since this isn't a real app widget. 
        mAppWidgetHost.deleteAppWidgetId(appWidgetId);
        //scold user for disobedience 
    } else { 
        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 { 
            // Otherwise just add it 
            onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
Connect your IDE to all the code out there  Get Codota for Java