无法始终从另一个活动启动 DevicePolicyManager 活动
我有一些奇怪的问题。当我尝试从主活动启动 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);
我将非常感谢任何帮助,因为我完全陷入困境。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论