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会让游戏的压力变大,即使它是隐蔽的,如果同样的功能在其它的地方也是一样的,那么就要写 ...
随机推荐
- golang 通过exec Command启动的进程如何关闭的解决办法 以及隐藏黑色窗口
golang 通过exec Command启动的进程如何关闭的解决办法 在用exec包调用的其他进程后如何关闭结束,可以使用context包的机制进行管理,context包的使用详见:https:// ...
- noip2010 引水入城 bfs+贪心
如果能够实现,每个河边的城市对应的控制区域一定是一条线段. 所以直接bfs每个河边的城市,贪心线段的右端点 #include<cstdio> #include<cstring> ...
- BZOJ_1923_[Sdoi2010]外星千足虫_高斯消元+bitset
BZOJ_1923_[Sdoi2010]外星千足虫_高斯消元 Description Input 第一行是两个正整数 N, M. 接下来 M行,按顺序给出 Charles 这M次使用“点足机”的统计结 ...
- BZOJ_1058_[ZJOI2007]报表统计_STL
BZOJ_1058_[ZJOI2007]报表统计_STL Description 小Q的妈妈是一个出纳,经常需要做一些统计报表的工作.今天是妈妈的生日,小Q希望可以帮妈妈分担一些工 作,作为她的生日礼 ...
- HrbustOJ 1564 螺旋矩阵
Description 对于给定的一个数n,要你打印n*n的螺旋矩阵. 比如n=3时,输出: 1 2 3 8 9 4 7 6 5 Input 多组测试数据,每个测试数据包含一个整数n(1<=n& ...
- sql查询当前登陆人所管理的校区下的人员
StringBuilder sql = new StringBuilder("select accountId, concat( ',', GROUP_CONCAT(FIND_IN_SET( ...
- Android Gradle基于参数化配置实现差异化构建
一.背景: 项目中有一些特殊的需求,如个别渠道集成腾讯bugly,个别渠道集成易观统计,不同的渠道集成不同的推送策略(如Oppo渠道优先Opush推送),不同的渠道拥有不同的第三方登录集成等等.这些需 ...
- Python调用ansible API系列(二)执行adhoc和playbook
执行adhoc #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from collections import namedtuple ...
- Docker镜像细节
前言 只有光头才能变强. 文本已收录至我的GitHub仓库,欢迎Star:https://github.com/ZhongFuCheng3y/3y 回顾前面: 为什么需要Docker? Docker入 ...
- json转js对象方法,JS对象转JSON方法
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...