javaandroidgoogle-play-servicesgoogle-play-protect

How to check Google Play Protect status?


I'm creating an anti-virus software, and I would like to know if Google Play Protect is enabled or disabled? I'm using Java in Android Studio. Are there any permissions required to access this information?


Solution

  • You can check if Google Play Protect (also known as Verify Apps) is enabled using the SafetyNet Verify Apps API (see that link for more details, including a Kotlin version and an option to prompt the user to enable it if it's disabled).

    It's an asynchronous API, so you'll have to write a callback, something like:

    SafetyNet.getClient(context)
        .isVerifyAppsEnabled()
        .addOnCompleteListener(new OnCompleteListener<VerifyAppsUserResponse>() {
            @Override
            public void onComplete(Task<VerifyAppsUserResponse> task) {
                if (task.isSuccessful()) {
                    VerifyAppsUserResponse result = task.getResult();
                    if (result.isVerifyAppsEnabled()) {
                        // It's enabled, handle that case here
                    } else {
                        // It's not enabled, handle that case here
                    }
                } else {
                    // An error occurred, we don't know whether it's enabled
                }
            }
        });
    

    The context parameter would just be your this if you're calling it from an Activity or Service.