参考资料

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

Android打开自启动设置页面

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

代码

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

  1. package com.why.project.notificationsetutildemo.utils;
  2.  
  3. import android.content.ComponentName;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.net.Uri;
  7. import android.os.Build;
  8. import android.provider.Settings;
  9.  
  10. /**
  11. * Created by HaiyuKing
  12. * Used 自启动设置工具类
  13. * 参考资料:https://blog.csdn.net/jin_qing/article/details/53087538
  14. * https://blog.csdn.net/gxp1182893781/article/details/78027863
  15. * https://www.jianshu.com/p/35f937c262b9
  16. */
  17. public class AutoStartUtil {
  18.  
  19. public static final String HAS_OPEN_SETTING_AUTO_START = "hasOpenSettingAutoStart";//是否已经打开过设置自启动界面的标记,存储起来
  20.  
  21. /*打开自启动管理页*/
  22. public static void openStart(Context context){
  23. if(Build.VERSION.SDK_INT < 23){
  24. return;
  25. }
  26. Intent intent = new Intent();
  27. if(RomUtil.isEmui()){//华为
  28. ComponentName componentName = new ComponentName("com.huawei.systemmanager","com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity");
  29. intent.setComponent(componentName);
  30. }else if(RomUtil.isMiui()){//小米
  31. ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity");
  32. intent.setComponent(componentName);
  33. }else if(RomUtil.isOppo()){//oppo
  34. ComponentName componentName = null;
  35. if (Build.VERSION.SDK_INT >=26){
  36. componentName =new ComponentName("com.coloros.safecenter","com.coloros.safecenter.startupapp.StartupAppListActivity");
  37. }else {
  38. componentName = new ComponentName("com.color.safecenter", "com.color.safecenter.permission.startup.StartupAppListActivity");
  39. }
  40. intent.setComponent(componentName);
  41. //上面的代码不管用了,因为oppo手机也是手机管家进行自启动管理
  42. }else if(RomUtil.isVivo()){//Vivo
  43. ComponentName componentName = null;
  44. if (Build.VERSION.SDK_INT >=26) {
  45. componentName =new ComponentName("com.vivo.permissionmanager","com.vivo.permissionmanager.activity.PurviewTabActivity");
  46. }else {
  47. componentName = new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.SoftwareManagerActivity");
  48. }
  49. intent.setComponent(componentName);
  50. }else if(RomUtil.isFlyme()){//魅族
  51. // 通过测试,发现魅族是真恶心,也是够了,之前版本还能查看到关于设置自启动这一界面,
  52. // 系统更新之后,完全找不到了,心里默默Fuck!
  53. // 针对魅族,我们只能通过魅族内置手机管家去设置自启动,
  54. // 所以我在这里直接跳转到魅族内置手机管家界面,具体结果请看图
  55. ComponentName componentName = ComponentName.unflattenFromString("com.meizu.safe" +
  56. "/.permission.PermissionMainActivity");
  57. intent.setComponent(componentName);
  58. }else {
  59. // 以上只是市面上主流机型,由于公司你懂的,所以很不容易才凑齐以上设备
  60. // 针对于其他设备,我们只能调整当前系统app查看详情界面
  61. // 在此根据用户手机当前版本跳转系统设置界面
  62. if (Build.VERSION.SDK_INT >= 9) {
  63. intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
  64. intent.setData(Uri.fromParts("package", context.getPackageName(), null));
  65. } else if (Build.VERSION.SDK_INT <= 8) {
  66. intent.setAction(Intent.ACTION_VIEW);
  67. intent.setClassName("com.android.settings",
  68. "com.android.settings.InstalledAppDetails");
  69. intent.putExtra("com.android.settings.ApplicationPkgName",
  70. context.getPackageName());
  71. }
  72. intent = new Intent(Settings.ACTION_SETTINGS);
  73. }
  74. try{
  75. context.startActivity(intent);
  76. }catch (Exception e){//抛出异常就直接打开设置页面
  77. Intent intent1 = new Intent(Settings.ACTION_SETTINGS);
  78. context.startActivity(intent1);
  79. }
  80. }
  81. }

使用

  1. 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. golang 通过exec Command启动的进程如何关闭的解决办法 以及隐藏黑色窗口

    golang 通过exec Command启动的进程如何关闭的解决办法 在用exec包调用的其他进程后如何关闭结束,可以使用context包的机制进行管理,context包的使用详见:https:// ...

  2. noip2010 引水入城 bfs+贪心

    如果能够实现,每个河边的城市对应的控制区域一定是一条线段. 所以直接bfs每个河边的城市,贪心线段的右端点 #include<cstdio> #include<cstring> ...

  3. BZOJ_1923_[Sdoi2010]外星千足虫_高斯消元+bitset

    BZOJ_1923_[Sdoi2010]外星千足虫_高斯消元 Description Input 第一行是两个正整数 N, M. 接下来 M行,按顺序给出 Charles 这M次使用“点足机”的统计结 ...

  4. BZOJ_1058_[ZJOI2007]报表统计_STL

    BZOJ_1058_[ZJOI2007]报表统计_STL Description 小Q的妈妈是一个出纳,经常需要做一些统计报表的工作.今天是妈妈的生日,小Q希望可以帮妈妈分担一些工 作,作为她的生日礼 ...

  5. HrbustOJ 1564 螺旋矩阵

    Description 对于给定的一个数n,要你打印n*n的螺旋矩阵. 比如n=3时,输出: 1 2 3 8 9 4 7 6 5 Input 多组测试数据,每个测试数据包含一个整数n(1<=n& ...

  6. sql查询当前登陆人所管理的校区下的人员

    StringBuilder sql = new StringBuilder("select accountId, concat( ',', GROUP_CONCAT(FIND_IN_SET( ...

  7. Android Gradle基于参数化配置实现差异化构建

    一.背景: 项目中有一些特殊的需求,如个别渠道集成腾讯bugly,个别渠道集成易观统计,不同的渠道集成不同的推送策略(如Oppo渠道优先Opush推送),不同的渠道拥有不同的第三方登录集成等等.这些需 ...

  8. Python调用ansible API系列(二)执行adhoc和playbook

    执行adhoc #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from collections import namedtuple ...

  9. Docker镜像细节

    前言 只有光头才能变强. 文本已收录至我的GitHub仓库,欢迎Star:https://github.com/ZhongFuCheng3y/3y 回顾前面: 为什么需要Docker? Docker入 ...

  10. json转js对象方法,JS对象转JSON方法

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...