Cannot always launch DevicePolicyManager activity from another activity

1.2k views Asked by At

I have some strange problem. When I try to launch DevicePolicyManager activity from my main activity, it loads properly. However, when I make a notification, call QuestionActivity (if user clicks the notification), and then try to call DevicePolicyManager activity from QuestionActivity, I get (logcat):

INFO/ActivityManager(104): Starting activity: Intent {
act=android.app.action.ADD_DEVICE_ADMIN
cmp=com.android.settings/.DeviceAdminAdd
(has extras) }
WARN/InputManagerService(104): Window already focused, ignoring focus
gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@4514a2d0

And nothing appears. This is strange for me, cause I'm able to launch different Android OS activity from QuestionActivity:

//This works 
Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intent);

But I cannot launch the DevicePolicyManager with:

//This works from main activity, but not from QuestionActivity
MyDeviceAdmin admin = new MyDeviceAdmin(this);
    Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
    intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
         admin.getDeviceAdminComponent());
    intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
            "Additional text explaining why this needs to be added.");
    startActivityForResult(intent, 234234234); 

I would be very grateful for any help, cause I'm completely stuck.

0

There are 0 answers