Example usage for android.app Activity getSystemService

List of usage examples for android.app Activity getSystemService

Introduction

In this page you can find the example usage for android.app Activity getSystemService.

Prototype

@Override
    public Object getSystemService(@ServiceName @NonNull String name) 

Source Link

Usage

From source file:Main.java

public static void hideKeyboard(Activity activity, IBinder token) {
    try {/*from www.j  a v a 2  s.c  om*/
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(token, 0);
        }
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
        }/*from   w w w  .java  2  s .c  o m*/
    }
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            View v = activity.getCurrentFocus();
            if (v != null)
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }//from   w  w w .jav  a  2  s  .c o  m
    }
}

From source file:Main.java

/*****************************************************
 * ---------------- * Soft keyboard * --------------------
 *
 *
 *
 ****************************************************/

public static void hideKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
    }/*from   w ww.j  a  v a2 s.com*/
}

From source file:Main.java

public static void hidenInput(Activity ctx) {
    // TODO Auto-generated method stub

    InputMethodManager imm = ((InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE));

    imm.hideSoftInputFromWindow(ctx.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

}

From source file:Main.java

public static void hideKeyboard(Activity activityRef, EditText editTextView) {
    //hide keyboard
    InputMethodManager imm = (InputMethodManager) activityRef.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editTextView.getWindowToken(), 0);
}

From source file:Main.java

public static void showInputMethodWindow(Activity activity, View view) {
    try {//from w w  w.  ja v  a 2s .  c om
        InputMethodManager inputMethodManager = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    } catch (Throwable e) {
    }
}

From source file:Main.java

public static void showSoftInput(Activity activity, View editText) {
    editText.requestFocus();//from ww w . j  a v  a 2  s.  c om
    InputMethodManager imm = ((InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE));
    imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
}

From source file:Main.java

/***
 * getIMEI : read the IMEI number of device The IMEI (14 decimal digits plus
 * a check digit) or IMEISV (16 digits) includes information on the origin,
 * model, and serial number of the device. The structure of the IMEI/SV are
 * specified in 3GPP TS 23.003//from www  . j a  va2 s  .  co  m
 * 
 * @param activity
 * @return 16 digit IMEI number of device ( padded with zeros)
 */
public static String getIMEI(Activity activity) {
    try {
        TelephonyManager telephonyManager = (TelephonyManager) activity
                .getSystemService(Context.TELEPHONY_SERVICE);
        String imei = telephonyManager.getDeviceId();
        if (imei == null)
            imei = Secure.getString(activity.getContentResolver(), Secure.ANDROID_ID);
        return imei;
    } catch (Exception e) {
    }
    return "EEEE-EEEE-EEEE-E";
}

From source file:Main.java

public static void hideSoftKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity
                .getSystemService(Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }//from w  w w .java2 s  . c  om
}