Example usage for android.os PowerManager isPowerSaveMode

List of usage examples for android.os PowerManager isPowerSaveMode

Introduction

In this page you can find the example usage for android.os PowerManager isPowerSaveMode.

Prototype

public boolean isPowerSaveMode() 

Source Link

Document

Returns true if the device is currently in power save mode.

Usage

From source file:com.fairphone.fplauncher3.Workspace.java

private void enableOverviewMode(boolean enable, int snapPage, boolean animated) {
    State finalState = Workspace.State.OVERVIEW;
    if (!enable) {
        finalState = Workspace.State.NORMAL;
    }// w w  w  . ja  v  a2  s .c  o  m
    PowerManager powerManager = (PowerManager) mLauncher.getSystemService(Context.POWER_SERVICE);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && powerManager.isPowerSaveMode()) {
        animated = false;
    }
    Animator workspaceAnim = getChangeStateAnimation(finalState, animated, 0, snapPage);
    if (workspaceAnim != null && !mIsSwitchingState) {
        onTransitionPrepare();
        workspaceAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator arg0) {
                onTransitionEnd();
            }
        });
        workspaceAnim.start();
    }
}