我想知道xiaomi是否可以提供任何应用程序的后台服务?
我在我的应用程序中有服务需要一直在后台运行,在所有设备中它的工作正常除了小米,它如何以编程方式完成?
我在我的应用程序中有服务需要一直在后台运行,在所有设备中它的工作正常除了小米,它如何以编程方式完成?
解决方法
适用于xiaomi,oppo,vivo和oneplus手机.
try { Intent intent = new Intent(); String manufacturer = android.os.Build.MANUFACTURER; if ("xiaomi".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.miui.securitycenter","com.miui.permcenter.autostart.AutoStartManagementActivity")); } else if ("oppo".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.coloros.safecenter","com.coloros.safecenter.permission.startup.StartupAppListActivity")); } else if ("vivo".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.vivo.permissionmanager","com.vivo.permissionmanager.activity.BgStartUpManagerActivity")); } else if("oneplus".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.oneplus.security","com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity")); } List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY); if (list.size() > 0) { context.startActivity(intent); } } catch (Exception e) { Crashlytics.logException(e); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。