My recommendation:
Create two versions of the application widget and use the resource value method to enable / disable.
in res / values /bools.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <bool name="atLeastHoneycomb">false</bool> <bool name="notHoneycomb">true</bool> </resources>
in res / values-v11 / bools.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <bool name="atLeastHoneycomb">true</bool> <bool name="notHoneycomb">false</bool> </resources>
in AndroidManifest.xml:
<receiver android:name="MyOldAppWidgetProvider" android:enabled="@bool/notHoneycomb"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/example_oldappwidget_info" /> </receiver> <receiver android:name="MyNewAppWidgetProvider" android:enabled="@bool/atLeastHoneycomb"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/example_newappwidget_info" /> </receiver>
source share