I’ve created three app widgets with different sizes for pre Honecomb versions of Android and one resizable scrollable listview widget for Honeycomb and later.
Since the widgets offer the same functionality and the one targeted for Honeycomb and later is resizable I would like to remove the other versions of the widget on API level 12 or later. Is this possible somehow?
As far as I can tell there doesn’t seem to be any way to disable a widget from getting registered by the AppWidgetService if it can find the AppWidgetProviderInfo resource file. So it seems that I can only include widgets on later versions but not exclude versions defined in xml folders that targets earlier API versions.
If it were a single app widget that had pre-HC or HC implementations, you could combine them into one
AppWidgetProviderand useres/xml-v11/andres/xml/to have different metadata.The only way I can think of to handle your scenario, though, is to mark some of the
AppWidgetProvidersas disabled in the manifest (android:enabled="false"), then enable and disable your providers on the first run of your app based onandroid.os.Build.VERSIONusingPackageManagerandsetComponentEnabledSetting(), to give you the right set. Since on Android 3.1+, the user will need to launch one of your activities to be able to add the app widget, anyway, you at least have the entry point in which to apply this logic.