Wednesday, July 6, 2011

[android-developers] Android 3.1 & DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN behavior

Running Galaxy Tab with Android 3.1.

Am starting intent DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN. Now,
in 3.1, onActivityResult is called immediately. Previous versions of
Android on Nexus One didn't call onActivityResult until the user
accepted or rejected the device admin.

I'm seeing this in the log:
I/ActivityManager(13574): Starting: Intent
{ act=android.app.action.ADD_DEVICE_ADMIN
cmp=com.android.settings/.DeviceAdminAdd (has extras) } from pid 24365
W/ActivityManager(13574): Activity is launching as a new task, so
cancelling activity result.

Generally, my app should expect this behavior; however, for adding a
device admin, it's a pain because my app wants to proceed knowing if
the user has accepted or rejected the device admin.

The sample code in
ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java
doesn't consider this case.

Is there a way to start ADD_DEVICE_ADMIN in such a way to defer the
call to onActivityResult until after the user has accepted or rejected
the device administrator?

- Steve

P.S. Did the behavior change or has my app just been getting lucky?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment