Oppo推送:启动OPPOA16的自动启动意图(com.coloros.safecenter)

我想为我的 OPPO A16 启动自动启动意图。我尝试了这个类:

class ManufacturerUtil {
    var POWER_MANAGER_INTENTS = mutableListOf(
        Intent().setComponent(ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")),
        Intent().setComponent(ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
        Intent().setComponent(ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),
        Intent().setComponent(ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
        Intent().setComponent(ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
        Intent().setComponent(ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
        Intent().setComponent(ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),
        Intent().setComponent(ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
        Intent().setComponent(ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),
        Intent().setComponent(ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.entry.FunctionActivity")).setData(
            Uri.p("mobilemanager://function/entry/AutoStart"))
    )
    fun startPowerSaverIntent(context: Context) {
        val settings = context.getSharedPreferences("ProtectedApps", Context.MODE_PRIVATE)
        val skipMessage = settings.getBoolean("skipProtectedAppCheck", false)
        if (!skipMessage) {
            val editor = settings.edit()
            var foundCorrectIntent = false
            for (intent in POWER_MANAGER_INTENTS) {
                if (isCallable(context, intent)) {
                    foundCorrectIntent = true
                    val dontShowAgain = AppCompatCheckBox(context)
                    dontShowAgain.text = "Do not show again"
                    dontShowAgain.setOnCheckedChangeListener { onView: CompoundButton?, isChecked: Boolean ->
                        editor.putBoolean("skipProtectedAppCheck", isChecked)
                        editor.apply()
                    }
                    AlertDialog.Builder(context)
                        .setTitle(Build.MANUFACTURER + " Protected Apps")
                        .setMessage(String.format("%s requires to be enabled in 'Protected Apps' to function properly.%n", context.getString(
                            R.string.app_name)))
                        .setView(dontShowAgain)
                        .setPositiveButton("Go to settings") { dialog: DialogIntece?, which: Int -> context.startActivity(intent) }
                        .setNegativeButton(android.R.string.cancel, null)
                        .show()
                    break
                }
            }
            if (!foundCorrectIntent) {
                editor.putBoolean("skipProtectedAppCheck", true)
                editor.apply()
            }
        }
    }
    private fun isCallable(context: Context, intent: Intent): Boolean {
        val list = context.packageManager.queryIntentActivities(
            intent,
            PackageManager.MATCH_DEFAULT_ONLY
        )
        return list.size > 0
    }
}

但它不起作用。当我检查 getInstalledApplications 时,我找不到一个我喜欢的。当我在互联网上检查时,一切都太老了,无法为我工作。

请帮忙

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(335)
Centos命令行访问网页:无法在Centos中使用命令行打开Chrome
上一篇
浏览器和服务器:同步客户端和服务器(andserver)
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(12条)