Adding android: widgetCategory = "keyguard | home_screen" while supporting the older sdk

I am trying to change my widget to fit on 4.2 lock screens. However, I still want to support the old SDKs.

I added

android:widgetCategory="keyguard|home_screen" 

to my appwidget provider in res / xml, but eclipse complains that "there is no resource id found for the widetCategory attribute in the android package"

If I raise minSdkVerion to 17, everything will be fine, but I want to still support the old SDKs.

I tried using resource qualifiers by creating separte res / xml-v17 / mywidget.xml and adding only the tag there, but the error still appears.

Thanks for any help.

Edit: I get it. using res / xml-v17 / folder is the answer. I just needed to change the build target for my project to 17 / 4.2.

+8
android android-widget android-4.2-jelly-bean
source share
2 answers

I think setting targetSdk to 17 enough. XML elements that do not make sense in older SDKs are simply ignored.

No need to put mywidget.xml in res/xml-v17

+9
source share

Place a copy of mywidget.xml in the res / xml-v17 / folder. This is aimed at Android 4.2, and all new properties in the appwidget-provider element will be available. Also right-click your project in eclipse and change the build target to: API Level 17 / Android 4.2

I saw your edit. But I think this makes it clearer that this question has an answer.

UPDATE: I can confirm the answer of Tomasz Hubalek. xml-v17 is not required. Changing the purpose of the assembly is enough. Right-click your project in eclipse and change the build target to: API Level 17 / Android 4.2

+6
source share

All Articles