如何在Android中以编程方式打开MIUI系统活动 [英] How to open MIUI system Activity programmatically in Android

查看:140
本文介绍了如何在Android中以编程方式打开MIUI系统活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to open the above page programmatically in Android?

推荐答案

据我所知,没有隐式的Intent可以打开此Activity.

As far as i know there is no implicit Intent to open this Activity.

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

To figure out how to do this explicitly, take a look at the Logcat output when opening this menu on your device to see what is going on. The flow should be handled by the ActivityManager at some point, so you can filter for it.

您应该在日志中查找类似的内容:

You should look for something like this in the log:

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

I/ActivityManager: START u0 {cmp=com.miui.powerkeeper/.ui.PowerHideModeActivity} from uid 1000 on display 0

获取此信息后,您只需创建一个适当的Intent,以便您可以自己启动相同的Activity:

After acquiring this information, you just have to create an appropriate Intent so you could start the same Activity yourself:

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组件.每当他们更改此组件的类名称或程序包时,您的代码就会中断.

On a side note, you shouldn't open OS components in an explicit way like this. Whenever they change the class name or package of this component, your code will break.

这篇关于如何在Android中以编程方式打开MIUI系统活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆