参考资料

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. MVC项目中怎么浏览html页面

    public class HomeController : Controller { public ActionResult Index() { //return View(); //return R ...

  2. BZOJ_1003_[ZJOI2006]物流运输_最短路+dp

    BZOJ_1003_[ZJOI2006]物流运输_最短路+dp 题意:http://www.lydsy.com/JudgeOnline/problem.php?id=1003 分析: 这种一段一段的显 ...

  3. BZOJ_1367_[Baltic2004]sequence_结论题+可并堆

    BZOJ_1367_[Baltic2004]sequence_结论题+可并堆 Description Input Output 一个整数R Sample Input 7 9 4 8 20 14 15 ...

  4. 关于CocoaPods的ruby镜像文件问题

    项目遇到第三方库更新问题 时   用到cocoaPods更换淘宝ruby镜像问题的时候  报错 后来 又在别处找了下 发现 用的是 https  如下: 后来细想  可能跟Xcode7 要求HTTPs ...

  5. Opencv(C++)实现二阶线性插值

    #include<opencv2\opencv.hpp> #include<iostream> using namespace cv; using namespace std; ...

  6. ionic3 懒加载在微信上缓存的问题

    1.懒加载是什么? 在ionic2中所有的组件.模块.服务.管道等都堆积在app.module.ts模块中,在页面初始化的时候会一次性加载所有的资源,导致资源过大,页面渲染缓慢,也导致app.modu ...

  7. RVM 安装 Ruby

    RVM 是一个命令行工具,可以提供一个便捷的多版本 Ruby 环境的管理和切换. https://rvm.io/ 如果你打算学习 Ruby / Rails, RVM 是必不可少的工具之一. 这里所有的 ...

  8. 查看keras自动给文件夹标号

    from tensorflow.contrib.keras.api.keras.preprocessing.image import ImageDataGenerator,img_to_array f ...

  9. Python一行代码实现快速排序

    上期文章排序算法——(2)Python实现十大常用排序算法为大家介绍了十大常用排序算法的前五种(冒泡.选择.插入.希尔.归并),因为快速排序的重要性,所以今天将单独为大家介绍一下快速排序! 一.算法介 ...

  10. Go:学习笔记兼吐槽(2)

    Go:学习笔记兼吐槽(1) Go:学习笔记兼吐槽(2) Go:学习笔记兼吐槽(3) 基本数据类型和string之间的转换 (1) 基本类型转string 使用 fmt.Sprintf(“%参数”, 表 ...