Selectively disable an Android service for certain API levels

夙愿已清 提交于 2020-01-20 08:24:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!