“受保护的应用"在华为手机上的设置以及如何处理 [英] "Protected Apps" setting on Huawei phones, and how to handle it

查看:838
本文介绍了“受保护的应用"在华为手机上的设置以及如何处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于Android 5.0的Huawei P8,用于测试应用程序.该应用程序需要在后台运行,因为它会跟踪BLE区域.

I have a Huawei P8 with Android 5.0 that I'm using for testing an app. The app needs to be running in the background, as it tracks BLE regions.

我发现华为内置了一个称为受保护的应用程序"的功能",可以通过电话设置(电池管理器>受保护的应用程序)进行访问.这样一来,关闭屏幕后,选定的应用程序即可继续运行.

I've discovered that Huawei has built in a "feature" called Protected Apps, that can be accessed from the phone settings (Battery Manager > Protected Apps). This allows elected apps to keep running after the screen is turned off.

对华为而言是明智的选择,但对我而言不幸的是,它似乎已选择加入,即默认情况下应用程序已退出,您必须手动将其放入. 这不是问题,因为我可以在FAQ或印刷文档中为用户提供有关此修复程序的建议,但我最近安装了Tinder(出于研究目的!),并注意到它已自动放入受保护列表中.

Sensibly for Huawei, but unfortunately for me, it looks like it's opt-in, i.e. apps are out by default, and you have to manually put them in. This isn't a showstopper, as I can advise users in an FAQ or printed documentation about the fix, but I recently installed Tinder (for research purposes!), and noticed that it was put in the protected list automatically.

有人知道我该如何为我的应用程序做到这一点吗?清单中是否有设置?是因为它是流行的应用程序,华为已经为Tinder启用了它吗?

Does anyone know how I can do this for my app? Is it a setting in the manifest? Is it something Huawei has enabled for Tinder because it's a popular app?

推荐答案

if("huawei".equalsIgnoreCase(android.os.Build.MANUFACTURER) && !sp.getBoolean("protected",false)) {
        AlertDialog.Builder builder  = new AlertDialog.Builder(this);
        builder.setTitle(R.string.huawei_headline).setMessage(R.string.huawei_text)
                .setPositiveButton(R.string.go_to_protected, 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);
                        sp.edit().putBoolean("protected",true).commit();
                    }
                }).create().show();
    }

这篇关于“受保护的应用"在华为手机上的设置以及如何处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆