Wednesday, August 24, 2011

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

Seems like something broken in 3.X.

DeviceAdminAdd activity is launched in new task by default.
Here is the activity stack log (Samsung Galaxy Tab, GT-P7510, Android
3.1, build: HMJ37.UEKF3):
Running activities (most recent first):
TaskRecord{40ae51f8 #52 I com.android.settings/.DeviceAdminAdd}
Run #4: ActivityRecord{40ae4fa8
com.android.settings/.DeviceAdminAdd}
TaskRecord{4262f7c0 #50 A com.example.android.apis}
Run #3: ActivityRecord{4177ca50
com.example.android.apis/.app.DeviceAdminSample$Controller}
Run #2: ActivityRecord{41551f60
com.example.android.apis/.ApiDemos}
Run #1: ActivityRecord{40b8e290
com.example.android.apis/.ApiDemos}

Device admin activity was started from DeviceAdminSample$Controller
using startActivityForResult with no additional intent flags (no
forcing for a new task).

Seems that settings.apk now declares this activity with launchMode
"singleTask" or "singleInstance". And application cannot start it in
it's own task and as the result cannot get the result from it.

It should be reported as an issue where 3rd-party applications cannot
get the result of DeviceAdminAdd user action.
We can get the event
com.example.android.apis.app.DeviceAdminSample.onEnabled(Context,
Intent), but cannot get the cancel event when user clicks Cancel on
this screen.

---
Gennadi Kudrjavtsev

On Jul 6, 11:08 pm, Steve <rascal2...@gmail.com> wrote:
> 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