rony l
rony l

Reputation: 6022

programmatically enable android device administration

I want to write tests for an application that uses the android device administration API . My problem is that the user needs to manually grant one-time approval for the application to have admin rights, otherwise a SecurityException is thrown at runtime.

a user can manually enable/disable admin rights for applications by going to settings->location & security -> select device administators. I would like to do it programmatically from within an AndroidTestCase.

Upvotes: 4

Views: 4066

Answers (1)

rony l
rony l

Reputation: 6022

I did not find a way to grant admin automatically.

Luckily, however, the AVD remembers that the application was granted admin and does not revoke it after installing a later version of the same app. Thus, after a manual one-time process of enabling admin on the emulator I can run all my tests that require admin, as long as i don't switch to another AVD.

Upvotes: 3

Related Questions