“Protected Apps” setting on Huawei phones, and how to handle it

后端 未结 7 1530
-上瘾入骨i
-上瘾入骨i 2020-11-22 09:48

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 t

7条回答
  •  無奈伤痛
    2020-11-22 10:04

    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();
        }
    

提交回复
热议问题