@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public boolean isPlacedOnLockscreen(Context context, int appWidgetId ){
if( Build.VERSION.SDK_INT < 17 ){
return false;
}
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
Bundle myOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
int category = myOptions.getInt(
AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
return category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
}
ただしonDeletedからは読み出せないもよう。
回避策としては「データのクリア」を実行されないことを期待してPreferenceにappWidgetIdごとにどちらに置かれたら記憶させておくとかしますかね。

