您的位置:首页 > 移动开发

获取Android手机系统当前界面Activity;(第三方app跳转华为,小米,oppo,vivo的自启动管理)

2016-11-17 11:07 2381 查看
需求:第三方app跳转华为手机的受保护后台;小米手机的自启动管理;oppo手机的某个app的后台冻结;vivo手机的加速白名单;

执行这个指令 adb shell dumpsys activity top

(要是出现adb用不了,error:unknown host service的解决方法

http://www.360doc.com/content/15/0509/22/23129045_469300718.shtml



把图片中红线的内容添加到Intent中进行跳转:

Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = null;
if (phoneModel.equals("1")) {//华为
comp = ComponentName
.unflattenFromString("com.huawei.systemmanager/.optimize.process.ProtectActivity");
} else if (phoneModel.equals("2")) {//小米
comp = ComponentName
.unflattenFromString("com.miui.securitycenter/com.miui.permcenter.autostart.AutoStartManagementActivity");
} else if (phoneModel.equals("3")) {//vivo
comp = ComponentName
.unflattenFromString("com.iqoo.secure/.ui.phoneoptimize.AddWhiteListActivity");
} else if (phoneModel.equals("4")) {//oppo
comp = ComponentName
.unflattenFromString("com.coloros.oppoguardelf/com.coloros.powermanager.fuelgaue.PowerUsageModelActivity");
}
intent.setComponent(comp);
startActivity(intent);


然后就可以测试了;这边的oppo手机只是到了设置中的其他界面?(因为我没有oppo手机);要是本人有的话,可以先把app下载下来。然后在设置中其他界面点击app进入的界面通过指令就可以获取包名和类名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android
相关文章推荐