我正在尝试获取我的小部件的所有ACTIVE实例的列表.在我的AppWidgetProvider的OnUpdate方法中,我正在执行以下操作:
// Get all ids
ComponentName thisWidget = new ComponentName(context, this.getClass());
int[] lastWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
Run Code Online (Sandbox Code Playgroud)
问题是,如果您将小部件添加到主屏幕然后将其删除,getAppWidgetIds仍会返回一个列表,其中包含您刚刚删除的小部件的ID.
有没有办法只检索主屏幕上活动的小部件的ID?