Example usage for android.appwidget AppWidgetHost deleteAppWidgetId

List of usage examples for android.appwidget AppWidgetHost deleteAppWidgetId

Introduction

In this page you can find the example usage for android.appwidget AppWidgetHost deleteAppWidgetId.

Prototype

public void deleteAppWidgetId(int appWidgetId) 

Source Link

Document

Stop listening to changes for this AppWidget.

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 {//from   w  ww.j  a  va  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);
    }
}