Closed abhi0611 closed 7 years ago
You're making 2 async calls and expecting them to work in sequence. i.e. You're asking to create a PIN, and then asking them to unlock before they've had the chance to even choose one.
You're getting that exception for the same reason: you're showing a dialog and then immediately moving to another Activity.
If you want to prevent them from getting to the success without a PIN, check to see if a PIN exists before using the unlocker. e.g.
@Override
public void onResume(){
super.onResume();
if(LockingHelper.hasSavedPIN(this))
showUnlockDialog();
else
new CreateLockDialogBuilder(this, new CreateLockDialogBuilder.LockCreationListener(){
public void onLockCanceled(){
finish(); // No PIN entered, don't let them through
} // Dialog was closed without entry
public void onLockSuccessful(){
showUnlockDialog();
}})
.show();
}
private void showUnlockDialog(){
ActionLockingHelper.unlockIfRequired(this, new UnlockDialogBuilder.UnlockEventListener() {
public void onCanceled() {
finish(); // No PIN entered, don't let them through
} // Dialog was closed without entry
public void onUnlockFailed(String reason) {
finish(); // No PIN entered, don't let them through
} // Not called with default Dialog, instead is handled internally
public void onUnlockSuccessful() {
Intent intent = new Intent(MainActivity.this, WelcomeClass.class);
startActivity(intent);
}
});
}
Hello @mattsilber ,
Sorry, I forgot to write to you. I got your point I was making asyc calls, thanks for the explanation and I was looking for has saved pin function in other two java classes not inside the lockingHelper class there I was going wrong. Thanks for the help, I think you can close this issue.
Hello @mattsilber ,
Please find my code below: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
When I am running the code from android studio, it gets installed in my phone and directly opens the WelcomeClass activity rather than asking for "Enter a 4-digit code to lock app". When I press back at that time it is asking me for the lock at that time it works fine but I am not sure why it is going directly to the next activity before lock. Getting exception as well "E/WindowManager: android.view.WindowLeaked:". Also if I clicked outside the dialog box, it does not exit the program it continues with the next activity, ideally it should not let you proceed if you touched outside the dialog box.