I am making an Android app that checks if certain security features are enabled on your phone. For example, if you have enabled a password, or your data is encrypted on your phone.
For some reason, the application needs to run twice to check and check if these security features are enabled on the phone or not, and this is the problem I'm trying to solve. I would like it to test and see if security features are enabled when creating the application and when you first launch the application, and not the second time.
I am testing whether these functions are included in the onStart() function in my MainActivity file. I have included the function code below:
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @SuppressLint("NewApi") public void onStart() { super.onStart(); //determine if phone uses lock pattern //It returns 1 if pattern lock enabled and 0 if pin/password password enabled ContentResolver cr = getBaseContext().getContentResolver(); lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED, 0);//Settings.System //returns 1 if pin/password protected. 0 if not KeyguardManager keyguardManager = (KeyguardManager) getBaseContext().getSystemService(Context.KEYGUARD_SERVICE); if( keyguardManager.isKeyguardSecure()) { //it is pin or password protected pinPasswordEnable=1; } else { //it is not pin or password protected pinPasswordEnable=0; }//http://stackoverflow.com/questions/6588969/device-password-in-android-is-existing-or-not/18716253
If any other code needs to be sent to answer this question, just let me know and thanks for your help. Perhaps the problem is related to super.onStart();
Does anyone think a pop-up screen can help solve the problem?
source share