0

I want to set password policy on screen lock and now I use setPasswordQuality(ComponentName admin, int quality) in DevicePolicyManager but this method is deprecated on API 31 and they add new method(setRequiredPasswordComplexity(passwordComplexity : Int)). I can use this method in API < 31? If I can,how should I use it? https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setRequiredPasswordComplexity(int)

nazanin
  • 51
  • 6

2 Answers2

1

As the documentation already states the method was added in API 31 and since there is no backward compatibility library for this so this functionality can only be used on devices with api 31 or above

Taranmeet Singh
  • 1,199
  • 1
  • 11
  • 14
0

I think your problem might solve here. You can check the build version by

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
                        // Do something for version 31 and above versions
} else{
                        // do something for phones running an SDK before 31
                    }
Ajay K S
  • 350
  • 1
  • 5
  • 16