How To Check If The Device Has Lock Screen Setup In Android


Smart Phones Have Been Enhancing Their User Privacy Over Years To Now. Starting From PIN (Personal Identification Number) To Fingerprint & Face Recognition. This Will Give The User Freedom Over Their Android Device.

As An Android App Developer You Might Be Wondering How You Can Check If The Android Device Has Been Secured By PIN(Personal Identification Number), Pattern, Fingerprint , Face Recognition Or Any Other Security Feature Supported By The Android Device. For This Purpose Their Is An Android Built-in Class Called KeyguardManager. This Class Hold Methods Related To The Security Of The Android Device. In This Tutorial We Will Cover On How We Can Check If The Device Has Any Security Setup.

Step1. Create Or Open An Existing Android Project.

Step2. In Your Project MainActivity.java Or Any Activity You Want To Check Security Setup Add The Following Import Statements.

import android.content.Context;
import android.app.KeyguardManager;

Step3. After That Define The Keyguard Manager Class As Follows.

KeyguardManager keyguardmanager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);

Step4. To Check The Security Setup You Can Use KeyguardManager isKeyguardSecure Boolean Method As Follows.

if(keyguardmanager.isKeyguardSecure()){
  //The Device Has Security Setup
} else {
//The Device Doesn't Have Any Security Setup
}

Step5. Run Your Project Now You Will Be Able To Get The Security Setup Status Of The Android Device.


             Thank You For Reading

Comments

Popular posts from this blog

How To Create First NodeJS Application In Android

How To Create PDF Reader App In Android

Color Picker In Sketchware Pro