2017-01-09 2 views
-2

내 코드에서 사용자가 최대 시도 횟수를 초과하여 인증에 실패하면 사용자를 기본 페이지로 안내하기 만하며 사용자가 여전히 인증 페이지에 액세스하여 성공적으로 인증 될 때까지 시도를 계속할 수 있습니다. 그래서 여기 최대 시도 횟수를 초과하면 기능/버튼 차단

public void onAuthenticationFailed() { 

    //Add one to the number of attempts taken 
    attemptCount += 1; 

    if (attemptCount < maxAttemptAllowance) { 
     super.onAuthenticationFailed(); 
     Toast.makeText(context, "Fingerprint Authentication Failed, Please Try Again", Toast.LENGTH_SHORT).show(); 
    } else { 
     //here is where the system block user if they exceed the maximum attempts 
     Toast.makeText(context, "Exceed maximum attempts, try again in 5 minutes later", Toast.LENGTH_SHORT).show(); 
     context.startActivity((new Intent(context, Main.class))); 
    } 
} 

, 내 질문은 사용자가 최대 시도를 초과하는 경우 어쨌든 난/제한/차단 기능을 해제하지만 5 분 동안이 아니라 전체 시스템을 수있다이다. 사전에

감사 만약 내가 정말이 문제

답변

1

스토어 현재 시간과 함께 SharedPreference의 조건에 대한 아이디어/논리를 가지고 있지 않는 한, 나에게 방법을 제안하고자 U 사람이해도 너무 앱이 닫히고 값이 계속 유지됩니다. 이런 일을하는 것이 더 좋은 선택입니다. :)

0

다음은 지연의 작동 예제입니다. 단추를 숨기고 (필요에 따라 수정할 수 있음) 단추를 다시 표시 할 남은 시간을 표시합니다.

private CountDownTimer delay_timer; 
public void Delay_Timer(final int length){ 

    int min; 
    Log.e("Delay timer"," Running "); 
    delay_timer = new CountDownTimer(length*1000, 1000) { 
     public void onTick(long millisUntilFinished) { 
      Log.e("Delay timer"," onTick "+"" +(millisUntilFinished/1000)+ " Seconds remaining."); 
      if(delay!=null) delay.setText("Button will be Enabled in "+SecToMin(millisUntilFinished/1000)+" sec."); 
     } 
     public void onFinish() { 
      enable_next(); 
     } 

    }; 
    try{ 
     disable_next(); 
     delay_timer.start(); 
    }catch (Exception ex){ 
     Log.e("Delay excpt"," "+ex.getMessage()); 
     enable_next(); 
    } 
} 

private String SecToMin(long totalSecs){ 
    long hours = totalSecs/3600; 
    long minutes = (totalSecs % 3600)/60; 
    long seconds = totalSecs % 60; 

    String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds); 
    return timeString; 
} 

public void Stop_recording_timer(){ 
    delay_timer.cancel(); 
} 

private void enable_next(){ 
    if(submit!=null){ 
     delay.setText(""); 
     submit.setVisibility(View.VISIBLE); 
    } 
} 

private void disable_next(){ 
    if(submit!=null){ 
     submit.setVisibility(View.INVISIBLE); 
    } 
} 

시도가 전화를 초과하면.

if(exceeds){ 
    Delay_Timer(time_in_secs); 
    } 
관련 문제