In my app, i want to enable auto start when user is logging into app. So i am using like below
val powerManagerIntent = arrayOf(
Intent().setComponent(
ComponentName(
"com.huawei.systemmanager",
"com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"
)
),
Intent().setComponent(
ComponentName(
"com.huawei.systemmanager",
"com.huawei.systemmanager.optimize.process.ProtectActivity"
)
),
Intent().setComponent(
ComponentName(
"com.huawei.systemmanager",
"com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity"
)
)
)
And
for (intent in Utils.powerManagerIntent) if (packageManager.resolveActivity(
intent,
PackageManager.MATCH_DEFAULT_ONLY
) != null
) {
MaterialAlertDialogBuilder(
this@StartChildModeActivity,
R.style.MyThemeOverlay_MaterialComponents_MaterialAlertDialog)
.setTitle("Enable AutoStart")
.setMessage("Please allow AppName to always run in the background,else our services can't be accessed.")
.setCancelable(false)
.setNegativeButton(resources.getString(R.string.btn_cancel)) { dialog, _ ->
dialog.dismiss()
}
.setPositiveButton("ALLOW") { dialog, _ ->
}.show()
}
Huawei device is working fine and honor is crashing when trying this. Any help is much appreciated