gpt4 book ai didi

android - com.huawei.systemmanager/com.huawei.systemmanager.optimize.process.ProtectActivity};您是否已在 AndroidManifest.xml 中声明此 Activity ?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:36:06 24 4
gpt4 key购买 nike

将应用程序放入 protected 应用程序列表时,我在 huawei nexus 6p 上遇到此错误。

"UncaughtException: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.huawei.systemmanager/com.huawei.systemmanager.optimize.process.ProtectActivity}; have you declared this activity in your AndroidManifest.xml?"

我正在使用此代码将应用程序放入 protected 应用程序列表中

if ("huawei".equalsIgnoreCase(Build.MANUFACTURER) && !settingsManager.getKeyStateProtectedApp()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Is app killing?").setMessage("Add LastingSales to protected apps list to keep it running in background.")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
startActivity(intent);
settingsManager.setKeyStateProtectedApp(true);
}
}).create().show();
}

这里的问题是,这不是我可以在 list 中声明的​​我自己的 Activity 。我还需要在 list 中声明它吗?如果我必须这样做,我该怎么做?

已解决 原因是 huawei nexus 6p 有纯 android,因此没有这样的 Activity 。但代码落在那里是因为 Build.MANUFACTURER 返回“huawei”。但是 Build.BRAND 返回“google”,因此添加了额外的检查作为

if ("huawei".equalsIgnoreCase(Build.MANUFACTURER) && !"google".equalsIgnoreCase(Build.BRAND) && !settingsManager.getKeyStateProtectedApp()

最佳答案

if 子句需要仔细检查制造商和品牌,以便它只在适合的手机上运行。

关于android - com.huawei.systemmanager/com.huawei.systemmanager.optimize.process.ProtectActivity};您是否已在 AndroidManifest.xml 中声明此 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47786535/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com