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 hideSoftInputMethod(Activity activity, View view) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void onClickHideKeyboard(Activity activity, View view) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

From source file:Main.java

private static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    InputMethodManager m = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (m != null) {
        m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }//from   w  ww . j  a  v a 2  s. c o  m
}

From source file:Main.java

public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}

From source file:Main.java

public static void showInputMethodWindow(Activity activity, View view) {
    try {/*from w  w  w. ja v  a 2s .  co  m*/
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view,
                InputMethodManager.SHOW_IMPLICIT);
    } catch (Throwable th) {
        th.printStackTrace();
    }
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow((activity).getCurrentFocus().getWindowToken(), 0);
}

From source file:Main.java

/**
 * Hide input method./*from   w  w w.  j  a  v a 2 s  . c o  m*/
 *
 * @param activity
 */
public static void hideInputMethod(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    View currentFocus = activity.getCurrentFocus();
    if (currentFocus != null) {
        imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

From source file:Main.java

public static void showKeyoard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(),
            InputMethodManager.SHOW_FORCED);
}

From source file:Main.java

/**
 *
 * @param activity//from  w w  w.j av  a  2 s  . c  o  m
 * @return
 */
public static boolean isGPSEnabled(Activity activity) {
    final LocationManager manager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
    if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        return true;
    }

    return false;
}