Code example for InputMethodService

Methods: getWindow

2
 
    /** 
     * Switches to Voice IME. 
     */ 
    public void startVoiceRecognition(String language) {
        InputMethodManager inputMethodManager = getInputMethodManager(mInputMethodService);
 
        InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(inputMethodManager);
 
        if (inputMethodInfo == null) {
            return; 
        } 
 
        inputMethodManager.setInputMethod(mInputMethodService
                .getWindow().getWindow().getAttributes().token, inputMethodInfo.getId());
 
		/*inputMethodManager.setInputMethodAndSubtype(mInputMethodService 
				.getWindow().getWindow().getAttributes().token, 
				inputMethodInfo.getId(), 
				getVoiceImeSubtype(inputMethodManager, inputMethodInfo));*/ 
    }