Android InputMethodService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android InputMethodService class.

This code example shows how to use the following methods:getWindow
 
    /** 
     * Switches to Voice IME. 
     */ 
    public void startVoiceRecognition(String language) {
        InputMethodManager inputMethodManager = getInputMethodManager(mInputMethodService);
 
        InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(inputMethodManager);
 
        if (inputMethodInfo == null) {
            return; 
        } 
 
        inputMethodManager.setInputMethodAndSubtype(mInputMethodService.getWindow().getWindow()
                .getAttributes().token,
                inputMethodInfo.getId(),
                getVoiceImeSubtype(inputMethodManager, inputMethodInfo));
    } 
 
    private static InputMethodManager getInputMethodManager(InputMethodService inputMethodService) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCurrentInputConnection
		return inputMethodService.getCurrentInputEditorInfo();
	} 
 
	@Nonnull 
	private InputConnection getCurrentInputConnection() {
		InputConnection result = this.inputMethodService.getCurrentInputConnection();
		if (result == null) {
			result = NoInputConnection.getInstance();
		} 
		return result;
	} 
 
	@Override 
	public CharSequence getTypedText() {
		return typedText;
	} 
 
	@Override 
	public void clearTypedText() { 
		this.typedText.setLength(0);

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getWindow
        switchToTargetIME(imiId, mShortcutSubtype, context);
    } 
 
    private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
            final InputMethodService context) {
        final IBinder token = context.getWindow().getWindow().getAttributes().token;
        if (token == null) {
            return; 
        } 
        final InputMethodManager imm = mRichImm.getInputMethodManager();
        new AsyncTask<Void, Void, Void>() {
            @Override 
            protected Void doInBackground(Void... params) {
                imm.setInputMethodAndSubtype(token, imiId, subtype);
                return null; 
            } 
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } 
 
    public boolean isShortcutImeEnabled() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isInputViewShown
 
	public void pickSuggestionManually(int index) {
	} 
 
	protected void handleCharacter(int primaryCode, int[] keyCodes) {
		if (inputMethodService.isInputViewShown()) {
			if (state.isShifted()) {
				primaryCode = Character.toUpperCase(primaryCode);
			} 
		} 
 
		if (isAlphabet(primaryCode) && state.isPrediction()) {
			keyboardInput.append((char)primaryCode);
			updateShiftKeyState(keyboardInput.getCurrentInputEditorInfo());
			updateCandidates(); 
		} else { 
			keyboardInput.commitText(String.valueOf((char) primaryCode), 1);
		} 
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getWindow
    /** 
     * Switches to Voice IME. 
     */ 
    @Override 
    public void startVoiceRecognition(String language) {
        InputMethodManager inputMethodManager = getInputMethodManager(mInputMethodService);
 
        InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(inputMethodManager);
 
        if (inputMethodInfo == null) {
            return; 
        } 
 
        inputMethodManager.setInputMethodAndSubtype(mInputMethodService.getWindow().getWindow()
                .getAttributes().token,
                inputMethodInfo.getId(),
                getVoiceImeSubtype(inputMethodManager, inputMethodInfo));
    } 
 
    private static InputMethodManager getInputMethodManager(InputMethodService inputMethodService) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getWindow
 
    /** 
     * 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));*/ 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService
        return activities.size() > 0;
    } 
 
    private InputMethodManager getInputMethodManager() {
        return (InputMethodManager) mInputMethodService
                .getSystemService(Context.INPUT_METHOD_SERVICE);
    } 
 
    private void postResult(String recognitionResult) {
        mLastRecognitionResult = recognitionResult;
 
        // Request the system to display the IME. 
        getInputMethodManager().showSoftInputFromInputMethod(mToken,
                InputMethodManager.SHOW_IMPLICIT);
    } 
 
    @Override 
    public void onStartInputView() { 
        Log.i(TAG, "#onStartInputView");
        if (mLastRecognitionResult != null) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getWindow
 
        mHandler = new Handler();
    } 
 
    public void startVoiceRecognition(String language) {
        mToken = mInputMethodService.getWindow().getWindow().getAttributes().token;
 
        mServiceBridge.startVoiceRecognition(mInputMethodService, language);
    } 
 
    public static boolean isInstalled(InputMethodService inputMethodService) {
        PackageManager pm = inputMethodService.getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(
                RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
        return activities.size() > 0;
    } 
 
    private InputMethodManager getInputMethodManager() {
        return (InputMethodManager) mInputMethodService
                .getSystemService(Context.INPUT_METHOD_SERVICE);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService
    } 
 
    private boolean isNetworkAvailable() { 
        try { 
            ConnectivityManager connectivityManager = (ConnectivityManager) mInputMethodService
                    .getSystemService(
                    Context.CONNECTIVITY_SERVICE);
            final NetworkInfo info = connectivityManager.getActiveNetworkInfo();
            return info != null && info.isConnected();
        } catch (SecurityException e) {
            // The IME does not have the permission to check the networking 
            // status. We hope for the best. 
            return true; 
        } 
    } 
 
    /** 
     * Register a listener to receive a notification every time the status of 
     * Voice IME may have changed. The {@link Listener} should 
     * update the UI to reflect the current status of Voice IME. When 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android InputMethodService Questions & Answers:

See Code Examples for Android InputMethodService Methods: