2016-01-20 37 views
3

我使用Android-HomeKey-Locker來鎖定主鍵。它有效,但是如果家被鎖定。 Android鍵盤永遠不會打開,如果我在打開鍵盤時鎖定在家中,鍵盤無法工作。當主頁鍵被鎖定時鍵盤不工作

有什麼辦法解決這個問題嗎?

在我的應用程序中禁止回家是絕對必要的,並且沒有其他方法可以取代它。

+0

物理或虛擬主頁密鑰? –

+0

物理主頁鍵 – user3782779

回答

1

我在我目前的項目中面臨同樣的情況,我使用了相同的Home Key Locker lib。

我必須採取輸入我的Kiosk模式活動裏面的對話,鍵盤沒有顯示,所以我這樣做:

final Dialog d = new Dialog(this.activity); 
    d.requestWindowFeature(Window.FEATURE_NO_TITLE); 

    getHomeKeyLocker().unlock();  // Unlock before showing dialog 

    d.setContentView(R.layout.dialog); 

    final EditText edt = (EditText) d.findViewById(R.id.input); 

    Button btnSubmit = (Button) d.findViewById(R.id.btnOk); 
    btnSubmit.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      edt.setError(null); 

      String tempString = edt.getText().toString(); 

      try { 
       float value = Float.valueOf(tempString); 
       if (value >= 10 && value <= 400) { 
        // Correct value entered 
        getHomeKeyLocker().lock(activity); // Lock again after getting the value 
        d.dismiss(); 
       } else { 
        edt.setError("Enter correct value"); 
       } 
      } catch (NumberFormatException e) { 
       e.printStackTrace(); 
       edt.setError("Enter correct value"); 
      } 
     } 
    }); 

    d.show(); 

基本上,我顯示對話框之前剛剛解鎖活動並鎖定活動再次獲得價值後。