【问题标题】:“Protected Apps” setting on Android phonesAndroid 手机上的“受保护的应用程序”设置
【发布时间】:2020-11-25 21:58:34
【问题描述】:

我们可以要求用户通过使用(例如华为手机)来保护我们的应用:

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
startActivity(intent);

有没有办法知道应用程序是否受到保护?我试图避免要求用户保护应用程序,例如每次创建应用时。

对于其他意图,我可以使用:

List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(
                    new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:" + getPackageName()))
                    ,
                    PackageManager.MATCH_DEFAULT_ONLY);

System.out.println("MY_intent_TEST_1(looks always true): "+( list.size() > 0 ) );

PowerManager pwm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

System.out.println("MY_intent_TEST_2(true when whitelisted): "+ pwm.isIgnoringBatteryOptimizations(context.getPackageName()) );

附:我正在学习:"Protected Apps" setting on Huawei phones, and how to handle it

【问题讨论】:

    标签: java android android-intent permissions huawei-mobile-services


    【解决方案1】:

    由于相关接口未暴露,目前您无法得知应用是否受到保护。

    【讨论】:

    • 非常感谢@shirley。 “相关接口”是什么意思?
    • @user20191130 了解应用程序是否受到保护的界面。 :)
    猜你喜欢
    • 1970-01-01
    • 2015-10-16
    • 1970-01-01
    • 2018-03-17
    • 2012-12-09
    • 1970-01-01
    • 2010-09-13
    • 1970-01-01
    • 2021-03-12
    相关资源
    最近更新 更多