Using OS 2.2 DevicePolicyManager SDK classes on Android whilst supporting OS 2.1 devices

前端 未结 1 1396
离开以前
离开以前 2021-01-25 05:29

I want to use some DevicePolicyManager methods in my app. The DevicePolicyManager was introduced in OS 2.2, but my app must continue to run on OS 2.1 devices.

Here\'s

1条回答
  •  无人及你
    2021-01-25 06:20

    If I need to implement a DeviceAdminReceiver, will reflection work?

    Not really. You'd need to use conditional class loading, which means you may as well just go that route to begin with.

    Is anybody aware of any drawbacks or complications to it?

    Speaking on behalf of my little corner of "anybody", I'm not aware of any drawbacks. I'd use the VERSION_CODES constants on Build, though, rather than the integer (7). And, unless you're supporting 1.5, you can use SDK_INT on Build rather than SDK.

    Would you recommend reflection or conditional class loading for using DevicePolicyManager?

    Conditional class loading.

    Will I need a DeviceAdminReceiver, or can I detect whether the user has a suitable password, e.g. by repeatedly calling isActivePasswordSufficient in my app to confirm it has been done?

    That I can't answer. If you don't get another answer addressing this point, you might consider asking that in its own SO question.

    Any other tips if you have them

    Never get involved in a land war in Asia.

    0 讨论(0)
提交回复
热议问题