Attempt to display the Android keyboard. - Android Android OS

Android examples for Android OS:Keyboard

Description

Attempt to display the Android keyboard.

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;

import android.view.View;
import android.view.inputmethod.InputMethodManager;

public class Main {
    /**/*  w  ww .ja v a  2s .  c om*/
     * Attempt to display the Android keyboard.
     *
     * FIXME: This should not need to exist.
     * Android should always show the keyboard at the appropriate time. This method allows you to display the keyboard
     * when Android fails to do so.
     *
     * @param activity The current activity
     * @param view The currently focused view that will receive the keyboard input
     */
    public static void showSoftKeyboard(Activity activity, View view) {
        InputMethodManager keyboard = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        keyboard.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    }
}

Related Tutorials