我有一些奇怪的问题。当我尝试从我的主要活动启动 DevicePolicyManager 活动时,它会正确加载。但是,当我发出通知时,调用 QuestionActivity(如果用户单击通知),然后尝试从 QuestionActivity 调用 DevicePolicyManager 活动,我得到(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
什么都没有出现。这对我来说很奇怪,因为我可以从 QuestionActivity 启动不同的 Android 操作系统活动:
//This works
Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intent);
但我无法启动 DevicePolicyManager:
//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);
我将非常感谢任何帮助,因为我完全陷入困境。