参考资料

Android6.0 打开自启动管理页面(华为、小米)

Android打开自启动设置页面

Android 机型设置自启动的跳转界面

代码

注意:需要搭配《RomUtil【Android判断手机ROM,用于判断手机机型】》使用。

package com.why.project.notificationsetutildemo.utils;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings; /**
* Created by HaiyuKing
* Used 自启动设置工具类
* 参考资料:https://blog.csdn.net/jin_qing/article/details/53087538
* https://blog.csdn.net/gxp1182893781/article/details/78027863
* https://www.jianshu.com/p/35f937c262b9
*/
public class AutoStartUtil { public static final String HAS_OPEN_SETTING_AUTO_START = "hasOpenSettingAutoStart";//是否已经打开过设置自启动界面的标记,存储起来 /*打开自启动管理页*/
public static void openStart(Context context){
if(Build.VERSION.SDK_INT < 23){
return;
}
Intent intent = new Intent();
if(RomUtil.isEmui()){//华为
ComponentName componentName = new ComponentName("com.huawei.systemmanager","com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity");
intent.setComponent(componentName);
}else if(RomUtil.isMiui()){//小米
ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity");
intent.setComponent(componentName);
}else if(RomUtil.isOppo()){//oppo
ComponentName componentName = null;
if (Build.VERSION.SDK_INT >=26){
componentName =new ComponentName("com.coloros.safecenter","com.coloros.safecenter.startupapp.StartupAppListActivity");
}else {
componentName = new ComponentName("com.color.safecenter", "com.color.safecenter.permission.startup.StartupAppListActivity");
}
intent.setComponent(componentName);
//上面的代码不管用了,因为oppo手机也是手机管家进行自启动管理
}else if(RomUtil.isVivo()){//Vivo
ComponentName componentName = null;
if (Build.VERSION.SDK_INT >=26) {
componentName =new ComponentName("com.vivo.permissionmanager","com.vivo.permissionmanager.activity.PurviewTabActivity");
}else {
componentName = new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.SoftwareManagerActivity");
}
intent.setComponent(componentName);
}else if(RomUtil.isFlyme()){//魅族
// 通过测试,发现魅族是真恶心,也是够了,之前版本还能查看到关于设置自启动这一界面,
// 系统更新之后,完全找不到了,心里默默Fuck!
// 针对魅族,我们只能通过魅族内置手机管家去设置自启动,
// 所以我在这里直接跳转到魅族内置手机管家界面,具体结果请看图
ComponentName componentName = ComponentName.unflattenFromString("com.meizu.safe" +
"/.permission.PermissionMainActivity");
intent.setComponent(componentName);
}else {
// 以上只是市面上主流机型,由于公司你懂的,所以很不容易才凑齐以上设备
// 针对于其他设备,我们只能调整当前系统app查看详情界面
// 在此根据用户手机当前版本跳转系统设置界面
if (Build.VERSION.SDK_INT >= 9) {
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", context.getPackageName(), null));
} else if (Build.VERSION.SDK_INT <= 8) {
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName("com.android.settings",
"com.android.settings.InstalledAppDetails");
intent.putExtra("com.android.settings.ApplicationPkgName",
context.getPackageName());
}
intent = new Intent(Settings.ACTION_SETTINGS);
}
try{
context.startActivity(intent);
}catch (Exception e){//抛出异常就直接打开设置页面
Intent intent1 = new Intent(Settings.ACTION_SETTINGS);
context.startActivity(intent1);
}
}
}

使用

AutoStartUtil.openStart(mContext);//打开自启动设置界面

AutoStartUtil【打开自启动设置界面】的更多相关文章

  1. iOS10 打开APP设置界面和WIFI界面

    在iOS10以上,权限这块有了一些变化 首先在info的URL Types 添加  prefs 1.打开APP设置界面 //打开设置 let url:NSURL = NSURL(string: UIA ...

  2. 在iOS应用程序中打开设备设置界面及其中某指定的选项界面

    摘自:http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme [[UIApp ...

  3. 在app内打开自己app的专用设置界面

    在我们的APP中,可能会使用多种服务,例如定位.推送.相册.拍照.通讯录等.选择是否允许一般只出现在安装app后第一次打开时,可是我们依然需要在使用到某种服务的时候判断是否用户是否允许了该服务,因为用 ...

  4. iOS用户是否打开APP通知开关跳转到系统的设置界面

    1.检测用户是否打开推送通知  /** 系统通知是否打开 @return 是否打开 */ //检测通知是否打开iOS8以后有所变化 所以需要适配iOS7 + (BOOL)openThePushNoti ...

  5. Android 打开设置界面或者WiFi连接界面

    1.使用APP打开系统的设置界面或者WiFi连接界面 startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); //直接进入手机中的wifi网 ...

  6. react-native 打开设置界面

    iOS iOS打开设置还是比较简单的,使用Linking组件即可: Linking.openURL('app-settings:') .catch(err => console.log('err ...

  7. iOS开发之如何跳到系统设置里的各种设置界面

    跳到更多设置界面 除了跳到WiFi设置界面,能不能跳到其他的设置界面呢?比如:定位服务.FaceTime.音乐等等.都是可以的,一起来看看如何实现的! 定位服务 定位服务有很多APP都有,如果用户关闭 ...

  8. 安卓跳转到GPS设置界面

      /** * 监听GPS */ private void initGPS() { LocationManager locationManager = (LocationManager) this . ...

  9. Html5 Egret游戏开发 成语大挑战(九)设置界面和声音管理

    在上一篇中,简单的使用界面元素快速实现了一个游戏中的二级页面,这种直接在游戏页面上做UI的做法并不太好,原因是,UI会让游戏的压力变大,即使它是隐蔽的,如果同样的功能在其它的地方也是一样的,那么就要写 ...

随机推荐

  1. 前端BUG监控神器

    有时候,看到用户的反馈,我们往往会一脸茫然,因为反馈的信息太少了. 比如有用户反馈登录不了.为了解这个问题,一般的流程是这样的:首先试试自己能不能登录网站,发现没问题:然后查看后台日志,发现最近没有登 ...

  2. 如何解决开机出现Missing operating system的故障

    刚刚一哥们火急火燎的来找我,说他的笔记本开机出现一行字,进不了系统,好可怕,里面存了好多资料呢,让我给他看看,看能不能整好.看的出来,把他吓坏了.我开玩笑问他是不是遇到勒索的了,显示的那句话是不是&q ...

  3. ThreadPoolExecutor简介

    ThreadPoolExecutor简介 并发包中提供的一个线程池服务 23456789 public ThreadPoolExecutor(int corePoolSize,//线程池维护线程的最少 ...

  4. github上传文件的几句命令行

    1.首先进入要上传的本地目录,右键打开git命令行. 2.执行指令:git init    初始化本地仓库,这是会看到多了一个.git文件夹(如果没看到那就是电脑隐藏了). 3.执行命令:git ad ...

  5. mysql5.7连接不上可能的问题(针对新安装的mysql5.7可能出现的问题)

    "ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)" 今天刚刚安装好的mysql5. ...

  6. SDRAM读写状态解析

    SDRAM的写状态流程 IDLE状态到WRITE状态 (1)在IDLE状态需要先给ACT命令激活某一行,此时处于Row Active状态. (2)在Row Active状态之后,给Write命令则会进 ...

  7. Vuex的初探与实战

    1.背景 最近在做一个单页面的管理后台项目,为了提高开发效率,使用了Vue框架来开发.为了使各个部分的功能,独立结构更加清晰,于是就拆分了很多组件,但是组件与组件之间数据共享成了一个问题,父子组件实现 ...

  8. Group Convolution分组卷积,以及Depthwise Convolution和Global Depthwise Convolution

    目录 写在前面 Convolution VS Group Convolution Group Convolution的用途 参考 博客:blog.shinelee.me | 博客园 | CSDN 写在 ...

  9. Shiro安全框架【快速入门】就这一篇!

    Shiro 简介 照例又去官网扒了扒介绍: Apache Shiro™ is a powerful and easy-to-use Java security framework that perfo ...

  10. C# 操作Word目录——生成、删除目录

    目录,是指书籍.文档正文前所载的目次,将主要内容以一定次第顺序编排,起指导阅读.检索内容的作用.在Word中生成目录前,需要设置文档相应文字或者段落的大纲级别,根据设定的大纲级别可创建文档的交互式大纲 ...