AutoStartUtil【打开自启动设置界面】
参考资料
代码
注意:需要搭配《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【打开自启动设置界面】的更多相关文章
- iOS10 打开APP设置界面和WIFI界面
在iOS10以上,权限这块有了一些变化 首先在info的URL Types 添加 prefs 1.打开APP设置界面 //打开设置 let url:NSURL = NSURL(string: UIA ...
- 在iOS应用程序中打开设备设置界面及其中某指定的选项界面
摘自:http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme [[UIApp ...
- 在app内打开自己app的专用设置界面
在我们的APP中,可能会使用多种服务,例如定位.推送.相册.拍照.通讯录等.选择是否允许一般只出现在安装app后第一次打开时,可是我们依然需要在使用到某种服务的时候判断是否用户是否允许了该服务,因为用 ...
- iOS用户是否打开APP通知开关跳转到系统的设置界面
1.检测用户是否打开推送通知 /** 系统通知是否打开 @return 是否打开 */ //检测通知是否打开iOS8以后有所变化 所以需要适配iOS7 + (BOOL)openThePushNoti ...
- Android 打开设置界面或者WiFi连接界面
1.使用APP打开系统的设置界面或者WiFi连接界面 startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); //直接进入手机中的wifi网 ...
- react-native 打开设置界面
iOS iOS打开设置还是比较简单的,使用Linking组件即可: Linking.openURL('app-settings:') .catch(err => console.log('err ...
- iOS开发之如何跳到系统设置里的各种设置界面
跳到更多设置界面 除了跳到WiFi设置界面,能不能跳到其他的设置界面呢?比如:定位服务.FaceTime.音乐等等.都是可以的,一起来看看如何实现的! 定位服务 定位服务有很多APP都有,如果用户关闭 ...
- 安卓跳转到GPS设置界面
/** * 监听GPS */ private void initGPS() { LocationManager locationManager = (LocationManager) this . ...
- Html5 Egret游戏开发 成语大挑战(九)设置界面和声音管理
在上一篇中,简单的使用界面元素快速实现了一个游戏中的二级页面,这种直接在游戏页面上做UI的做法并不太好,原因是,UI会让游戏的压力变大,即使它是隐蔽的,如果同样的功能在其它的地方也是一样的,那么就要写 ...
随机推荐
- redis基础操作~~数据备份与恢复、数据安全、性能测试、客户端连接、分区
数据备份与恢复 数据备份redis save 命令用于创建当前数据库的备份. redis 127.0.0.1:6379> SAVE OK 该命令将在 redis 安装目录中创建dump.rdb文 ...
- React从入门到放弃之前奏(3):Redux简介
安装 npm i -S redux react-redux redux-devtools 概念 在redux中分为3个对象:Action.Reducer.Store Action 对行为(如用户行为) ...
- 数据保存策略(Retention Policies)
数据保存策略(Retention Policies) InfluxDB没有提供直接删除Points的方法,但是它提供了Retention Policies.主要用于指定数据的保留时间:当数据超过了指定 ...
- 1.1 为什么要使用lambda 表达式
第1章 lambda 表达式 1.1 为什么要使用lambda 表达式 1.2 lambda 表达式的语法 1.3 函数式接口 1.4 方法引用 1.5 构造器引用 1.6 变量作用域 1.7 默认方 ...
- KVM虚拟化环境准备
1. 概述2. 环境准备2.1 硬件环境2.2 软件环境2.2.1 YUM安装软件包2.2.2 环境检查2.2.3 启动libvirtd服务2.3 网络环境2.3.1 复制网卡配置文件2.3.2 修改 ...
- sql查询当前登陆人所管理的校区下的人员
StringBuilder sql = new StringBuilder("select accountId, concat( ',', GROUP_CONCAT(FIND_IN_SET( ...
- Redis+Restful 构造序列号和压力测试【后续】
大家还记上篇博文https://www.cnblogs.com/itshare/p/8643508.html,测试redis构造流水号的tps是600多/1s. 这个速度显然不能体现redis 集群在 ...
- J2EE相关概念,EJB/JNDI/JMS/RMI等
J2EE 四层模型 J2EE的核心API.组件.相关概念 JDBC(Java Database Connectivity) JNDI(Java Name and Directory Interface ...
- nuxt Window 或 Document未定义解决方案
概述 在用nuxt开发服务端渲染项目并引入第三方库的时候,经常会遇到window或document未定义的情况,原因是这个第三方库里面用到了window或者document,然后在服务端打包的时候,n ...
- React + TypeScript:元素引用的传递
React 中需要操作元素时,可通过 findDOMNode() 或通过 createRef() 创建对元素的引用来实现.前者官方不推荐,所以这里讨论后者及其与 TypeScript 结合时如何工作. ...