Selectively disable an Android service for certain

2019-01-28 08:37发布

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条回答
贼婆χ
2楼-- · 2019-01-28 09:33

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+

查看更多
登录 后发表回答