2016-04-24 71 views

回答

2

原來我只是不得不這樣做:

InputMethodManager im = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); 
    String list = im.getEnabledInputMethodList().toString(); 
    if(list.contains(<MY KEYBOARD ID>)){ 
    //Do something 
    } 
6

檢查下面的代碼: -

String packageLocal = getPackageName(); 
    boolean isInputDeviceEnabled = false; 
    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); 
    List<InputMethodInfo> list = inputMethodManager.getEnabledInputMethodList(); 

    // check if our keyboard is enabled as input method 
    for (InputMethodInfo inputMethod : list) { 
     String packageName = inputMethod.getPackageName(); 
     if (packageName.equals(packageLocal)) { 
      Toast.makeText(getApplicationContext(),"Your Keyboard Enable",Toast.LENGTH_SHORT).show(); 
     } 
    } 
+1

我者優先這個答案,因爲它是sillyly簡單,只需要複製過去的項目! – CodeToLife

+0

謝謝,兄弟!我登錄到StackOverflow只是爲了滿足你的答案。萬分感謝!!! – ArhatBaid

+0

@CodeToLife謝謝先生... –

相關問題