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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 viaPackageManagerandsetComponentEnabledSetting(). 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 yourStackViewimplementation andres/layout/for your non-StackViewimplementation. YourAppWidgetProvidercan check the API level and configure theRemoteViewsand related stuff accordingly.