Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 774
Sam Russell Avatar asked Nov 20 '12 07:11

Sam Russell


2 Answers

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

like image 116
Tomáš Hubálek Avatar answered Oct 21 '22 08:10

Tomáš Hubálek


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

like image 41
RoggA Avatar answered Oct 21 '22 08:10

RoggA