Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.view.View;

import android.view.inputmethod.InputMethodManager;

public class Main {
    /**
     * Close the soft key board
     */
    public static void closeSoftKeyBoard(Activity pActivity) {
        if (pActivity != null) {
            final InputMethodManager inputMethodManager = (InputMethodManager) pActivity
                    .getSystemService(Activity.INPUT_METHOD_SERVICE);
            if (inputMethodManager != null) {
                final View currentFocus = pActivity.getCurrentFocus();
                if (currentFocus != null) {
                    inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
                }

            }
        }
    }
}