Android跳转到手机自启动管理页面

前言

有时候,为了确保APP的后台正常运行,需要让用户去设置打开APP的自启动权限(或者改为手动管理/huawei)。为了更好的用户体验,在APP中可以直接跳转到手机的自启动管理页面或者权限管理页面。


应用启动管理页面

oppo/vivo是没有这个页面的
华为

  • 华为
ComponentName componentName = null;
int sdkVersion = Build.VERSION.SDK_INT;
try {
   
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    //跳自启动管理
    if (sdkVersion >= 28){
   //9:已测试
        componentName = ComponentName.unflattenFromString("com.huawei.systemmanager/.startupmgr.ui.StartupNormalAppListActivity");//跳自启动管理
    }else if (sdkVersion >= 26){
   //8:已测试
        componentName = ComponentName.unflattenFromString("com.huawei.systemmanager/.appcontrol.activity.StartupAppControlActivity");
    }else if (sdkVersion >= 23){
   //7.6:已测试
        componentName = ComponentName.unflattenFromString("com.huawei.systemmanager/.startupmgr.ui.StartupNormalAppListActivity");
    }else if (sdkVersion >= 21){
   //5
        componentName = ComponentName.unflattenFromString("com.huawei.systemmanager/com.huawei.permissionmanager.ui.MainActivity");
    }
    //componentName = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");//锁屏清理
    intent.setComponent(componentName);
    startActivity(intent);
}catch (Exception e){
   
	//跳转失败
}
  • 小米
Intent intent = new Intent();
try {
   
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ComponentName componentName = null;
    componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity");
    intent.setComponent(componentName)
  • 6
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值