Example usage for android.app Activity getWindow

List of usage examples for android.app Activity getWindow

Introduction

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

Prototype

public Window getWindow() 

Source Link

Document

Retrieve the current android.view.Window for the activity.

Usage

From source file:Main.java

@SuppressLint("InlinedApi")
public static void makeFullscreen(Activity activity) {
    //      if (!SkyUtility.isNexus()) return;
    //      if (SkyUtility.isNexusTablet()) return;
    activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    if (Build.VERSION.SDK_INT >= 19) {
        activity.getWindow().getDecorView()
                .setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    } else if (Build.VERSION.SDK_INT >= 11) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }/*ww w.j  a va 2 s. co m*/
}

From source file:Main.java

public static void initSystemBar(Activity activity) {
    if (android.os.Build.VERSION.SDK_INT > 18 && android.os.Build.VERSION.SDK_INT < 21) {
        Window window = activity.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    } else if (android.os.Build.VERSION.SDK_INT >= 21) {
        Window window = activity.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }/*from   w  w  w .  ja va2 s.com*/
}

From source file:Main.java

@SuppressLint("NewApi")
public static void setStatusBarColor(Activity mActivity, int color) {
    try {//ww w .j  a  v a2s. c o m
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            mActivity.getWindow().setStatusBarColor(color);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void closeSoftInput(Activity activity) {
    InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    im.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
}

From source file:com.example.library.inject.InjectUtil.java

public static void inject(Activity target) {
    init(target);//from   www  . j a  v  a2  s .co  m
    Class<? extends Object> targetClazz = target.getClass();
    View contentView = target.getWindow().getDecorView();
    InjectViewUtil.injectField(targetClazz, target, contentView);
    InjectEventUtil.injectMethod(targetClazz, target, contentView);
}

From source file:Main.java

public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager localInputMethodManager = (InputMethodManager) activity.getSystemService("input_method");
    IBinder localIBinder = activity.getWindow().getDecorView().getWindowToken();
    localInputMethodManager.hideSoftInputFromWindow(localIBinder, 0);
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@SuppressWarnings("unchecked")
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity,
        boolean includeStatusBar, @Nullable Pair... otherParticipants) {
    View decor = activity.getWindow().getDecorView();
    View statusBar = null;//  w ww.ja  v a 2 s  . c  o m
    if (includeStatusBar) {
        statusBar = decor.findViewById(android.R.id.statusBarBackground);
    }
    View navBar = decor.findViewById(android.R.id.navigationBarBackground);

    List<Pair> participants = new ArrayList<>(3);
    addNonNullViewToTransitionParticipants(statusBar, participants);
    addNonNullViewToTransitionParticipants(navBar, participants);
    // only add transition participants if there's at least one none-null element
    if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) {
        participants.addAll(Arrays.asList(otherParticipants));
    }
    return participants.toArray(new Pair[participants.size()]);
}

From source file:com.byoutline.kickmaterial.utils.LUtils.java

public static void setStatusBarColor(Activity activity, int color) {
    if (!hasL() || activity == null) {
        return;//w  ww .  j ava  2s . co m
    }

    activity.getWindow().setStatusBarColor(color);
}

From source file:net.tsz.afinal.FinalFragmentActivity.java

public static void initInjectedView(Activity activity) {
    initInjectedView(activity, activity.getWindow().getDecorView());
}