无法始终从另一个活动启动 DevicePolicyManager 活动

发布于 2024-10-20 10:59:43 字数 1248 浏览 1 评论 0原文

我有一些奇怪的问题。当我尝试从主活动启动 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文