2

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.

4

1 に答える 1

2

管理者を自動的に付与する方法が見つかりませんでした。

しかし幸いなことに、AVD はアプリケーションに管理者権限が付与されたことを記憶しており、同じアプリの新しいバージョンをインストールした後もそれを取り消すことはありません。したがって、エミュレーターで管理者を有効にする手動の 1 回限りのプロセスの後、別の AVD に切り替えない限り、管理者を必要とするすべてのテストを実行できます。

于 2011-04-26T14:39:04.900 に答える