温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - How to open MIUI system Activity programmatically in Android
android android-activity

其他 - 如何在Android中以编程方式打开MIUI系统活动

发布于 2020-03-28 23:35:55

在此处输入图片说明

是否可以在Android中以编程方式打开上述页面?

查看更多

查看更多

提问者
Shaifali Rajput
被浏览
15
earthw0rmjim 2017-07-28 20:32

据我所知,并没有隐式Intent地打开它Activity

要弄清楚如何明确执行此操作,请在打开设备上的此菜单时查看Logcat输出,以了解发生了什么情况。流程应ActivityManager在某个时候由处理,因此您可以对其进行过滤。

您应该在日志中查找以下内容:

I / ActivityManager:从显示屏上的uid 1000开始u0 {cmp = com.miui.powerkeeper / .ui.PowerHideModeActivity}

获取此信息后,您只需要创建一个适当的Intent内容即可Activity自己开始

try {
    Intent intent = new Intent();
    intent.setClassName("com.miui.powerkeeper",
        "com.miui.powerkeeper.ui.PowerHideModeActivity");

    startActivity(intent);
} catch (ActivityNotFoundException anfe) {
    // this is not an MIUI device, or the component got moved/renamed
}

附带说明一下,您不应以这种明确的方式打开OS组件。每当他们更改此组件的类名称或程序包时,您的代码就会中断。