onDisabled and onDeleted method not being called

故事扮演 提交于 2019-12-24 11:29:28

问题


For some reason, the onDisabled and onDeleted method of my widget is not getting called when i remove the widget from the homescreen. I don't know why.

Here's the code:

public class WidgetProvider2x1 extends AppWidgetProvider {

@Override
public void onEnabled(Context context) {

    Log.i("MyTag", "onEnabled");

    super.onEnabled(context);
}

@Override
public void onDeleted(Context context, int[] appWidgetIds) {

    Log.i("MyTag", "onDeleted");
    Toast.makeText(context, "onDeleted", Toast.LENGTH_SHORT).show();

    super.onDeleted(context, appWidgetIds);
    }

@Override
public void onDisabled(Context context) {

     Log.i("MyTag", "onDisabled");
     Toast.makeText(context, "onDisabled", Toast.LENGTH_SHORT).show();

     super.onDisabled(context);
}

LogCat also does not show anything.

来源:https://stackoverflow.com/questions/13988944/ondisabled-and-ondeleted-method-not-being-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!