I need to implement a widget that uses Stackview which is supported on sdk 11 and higher. My app uses sdk 8, so can I enable/disable a widget based on the sdk version?
If the app widget is to be totally unavailable, mark the <receiver>
as disabled in the manifest (android:enabled="false"
). Then, on first run of your app, check your version and conditionally enable the app widget via PackageManager
and setComponentEnabledSetting()
. The only downside is that your app widget will not show up as available until they launch your app for the first time.
If the app widget is simply to have different behavior on different versions, use res/layout-v11/
for your StackView
implementation and res/layout/
for your non-StackView
implementation. Your AppWidgetProvider
can check the API level and configure the RemoteViews
and related stuff accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With