简体   繁体   中英

adding android:widgetCategory=“keyguard|home_screen” while still supporting older sdk

I am trying to modify my widget so that it supports being placed on 4.2 lockscreens. However I still want to support older SDK's.

I added

android:widgetCategory="keyguard|home_screen"

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

If I raise the minSdkVerion to 17 everything works fine, but I want to still support older SDKs.

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

Thanks for any help.

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

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

No need to put mywidget.xml into res/xml-v17 folder

Put a copy of your mywidget.xml in res/xml-v17/ folder. This targets Android 4.2 and all new "properties on the appwidget-provider element will be avaible. Also right click your project in eclipse and change build target to: API level 17/ Android 4.2

I saw your Edit. But i think this makes it more clear that this question have an answer.

UPDATE: I can confirm Tomáš Hubálek answer. the xml-v17 is not needed. Changing Build target is enough. Right click your project in eclipse and change build target to: API level 17/ Android 4.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM