android - 如何进入荣耀10 Lite的自动启动权限页面?
问题描述
在我的应用程序中,我想在用户登录应用程序时启用自动启动。所以我使用如下
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"
)
)
)
和
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()
}
华为设备工作正常,尝试此操作时荣誉崩溃。任何帮助深表感谢
解决方案
请使用以下 2 个意图组件:
val powerManagerIntent = arrayOf(
Intent().setComponent(
ComponentName(
"com.huawei.systemmanager",
"com.huawei.systemmanager.optimize.process.ProtectActivity"
)
),
Intent().setComponent(
ComponentName(
"com.huawei.systemmanager",
"com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"
)
),
)
另外,请尝试在 AndroidManifest.xml 中添加以下权限:
<uses-permission android:name="com.huawei.permission.external_app_settings.USE_COMPONENT"/>
推荐阅读
- npm - mapbox-map-image-export 在 Ubuntu 服务器上返回一个未指定的错误“Error {}”
- google-cloud-dataflow - 是什么导致我的 Dataflow 作业被取消?
- python - scipy.optimize.dual_annealing 中允许哪些“访问”参数值?
- python - 在 Ubuntu 上处理 PSD 文件中文本层的文本
- javascript - 为什么我无法将 JSON 数据发送到 ipcRenderer
- flash - Flash 播放器不再在 Browserstack 上的浏览器中工作?
- python - Keras model.fit() 引发关于未指定参数“steps_per_epoch”的错误
- numpy - 向量化 GroupBy Pandas 数据框的函数
- java - 验证每个电子邮件地址 (Firebase)
- kubernetes - 如何在 Kubernetes 容器命令中使用环境变量?