问题
My Android app supports API 8+, however the Parse library seems to break completely on APIs less than 10 (and even a little bit on 10 too). I know how to disable blocks of code on certain API levels, but is there a way that a <service>
declared in AndroidManifest.xml
can be selectively enabled only for API 11+? (it also gets started up by the BOOT_COMPLETE
<intent>
which would also need to be disabled)
回答1:
Step #1: Create a res/values/bools.xml
file, with a bool
resource named i_can_haz_parse
, set to false
Step #2: Create a res/values-v11/bools.xml
file, with a bool
resource also named i_can_haz_parse
, set to true
Step #3: Have android:enabled="@bool/i_can_haz_parse"
on the components, like your service, that you want only on API Level 11+
来源:https://stackoverflow.com/questions/28503745/selectively-disable-an-android-service-for-certain-api-levels