Example usage for android.view Window addFlags

List of usage examples for android.view Window addFlags

Introduction

In this page you can find the example usage for android.view Window addFlags.

Prototype

public void addFlags(int flags) 

Source Link

Document

Convenience function to set the flag bits as specified in flags, as per #setFlags .

Usage

From source file:com.nbplus.vbroadlauncher.BaseActivity.java

public void acquireCpuWakeLock() {
    Log.e(TAG, "Acquiring cpu wake lock");
    if (mCpuWakeLock != null) {
        return;/*from   ww  w.ja  v a2 s.c o m*/
    }

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

    mCpuWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
            | PowerManager.ON_AFTER_RELEASE, "I'm your father");
    mCpuWakeLock.acquire();

    Window window = this.getWindow();
    mDefaultWindowFlags = window.getAttributes().flags;
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}

From source file:com.quaap.audiometer.MainActivity.java

public boolean startit() {
    if (checkMicrophoneAccess()) {
        mRecorderThread = new Thread(mMicLevelReader, "AudioListener Thread");
        mRecorderThread.start();//from w  ww . ja v  a2  s.co m
        Window w = this.getWindow();
        w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        return true;
    }
    return false;
}

From source file:dg.shenm233.mmaps.ui.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Window window = getWindow();
    window.getDecorView()/*from w  ww.j  av a 2  s.c  om*/
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(getResources().getColor(R.color.status_bar_color));

    setContentView(R.layout.activity_main);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    initNavigationView();

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.main_content, getMapsFragment(), MapsFragment.class.getName());
    ft.commit();
}

From source file:com.jiubai.jiubaijz.zxing.activity.CaptureActivity.java

private void initView() {
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_capture);

    ButterKnife.bind(this);

    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);/*from   w  w w .j a  v a  2s . co m*/
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    mScanLineImageView.startAnimation(animation);
}

From source file:com.jins_meme.bridge.AlertDialogFragment.java

@NonNull
@Override//from   w w  w .j a v a 2 s . c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    String type = getArguments().getString("type");

    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

    switch (type) {
    case "welcome":
        alert.setTitle(getString(R.string.welcome_title));
        alert.setMessage(getString(R.string.welcome_message));
        alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (mListener != null) {
                    mListener.doPositiveClick("welcome");
                }
            }
        });
        break;
    case "airplane":
        alert.setTitle(getString(R.string.airplane_mode_on_title));
        alert.setMessage(getString(R.string.airplane_mode_on_explain));
        alert.setNegativeButton(getString(R.string.exit), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Quit App...");

                if (mListener != null) {
                    mListener.doNegativeClick("airplane");
                }
            }
        });
        break;
    case "network":
        alert.setTitle(getString(R.string.not_connected_network_title));
        alert.setMessage(getString(R.string.not_connected_network_explain));
        alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (mListener != null) {
                    mListener.doPositiveClick("network");
                }
            }
        });
        alert.setNegativeButton(getString(R.string.exit), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Quit App...");

                if (mListener != null) {
                    mListener.doNegativeClick("network");
                }
            }
        });
        break;
    case "meme":
        alert.setTitle(getString(R.string.not_found_meme_title));
        alert.setMessage(getString(R.string.not_found_meme_explain));
        alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Close Alert Dialog...");

                if (mListener != null) {
                    mListener.doPositiveClick("meme");
                }
            }
        });
        alert.setNegativeButton(getString(R.string.exit), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Quit App...");

                if (mListener != null) {
                    mListener.doNegativeClick("meme");
                }
            }
        });
        break;
    case "app_id_secret":
        alert.setTitle(getString(R.string.incorrect_app_id_secret_title));
        alert.setMessage(getString(R.string.incorrect_app_id_secret_explain));
        alert.setNegativeButton(getString(R.string.exit), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Quit App...");

                if (mListener != null) {
                    mListener.doNegativeClick("meme");
                }
            }
        });
        alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Close Alert Dialog...");

                if (mListener != null) {
                    mListener.doPositiveClick("meme");
                }
            }
        });
        break;
    case "midi":
        alert.setTitle(getString(R.string.not_selected_midi_title));
        alert.setMessage(getString(R.string.not_selected_midi_explain));
        alert.setNegativeButton(getString(R.string.exit), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Quit App...");

                if (mListener != null) {
                    mListener.doNegativeClick("midi");
                }
            }
        });
        alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Log.d("DEBUG", "Close Alert Dialog...");

                if (mListener != null) {
                    mListener.doPositiveClick("midi");
                }
            }
        });
        break;
    case "hue":
        alert.setTitle(getString(R.string.hue_error_title));
        alert.setMessage(getString(R.string.hue_error_message));
        alert.setNegativeButton(getString(R.string.ok), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        break;
    }

    Dialog dialog = alert.create();

    Window window = dialog.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

    //return alert.create();
    return dialog;
}

From source file:com.example.locale.MainActivity.java

private void showDefaultLocale() {
    Locale locale = Locale.getDefault();
    setTitle(locale.getDisplayName());//from  w w w .  j a  va2s . c o m
    BitmapDrawable d = (BitmapDrawable) ImageUtil.getFlagIcon(this, locale.getCountry());
    if (d != null) {
        final Bitmap bitmap = d.getBitmap();
        mPaletteTask = new Palette.Builder(bitmap).generate(new Palette.PaletteAsyncListener() {
            @Override
            public void onGenerated(Palette palette) {
                mPaletteTask = null;
                int color = palette.getDarkVibrantColor(0);
                mToolbar.setBackgroundColor(color);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    Window window = getWindow();
                    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.setStatusBarColor(getDarkerColor(color));
                }
            }
        });
    }
}

From source file:org.kaaproject.kaa.demo.photoframe.MainActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setLightsOutMode(boolean enabled) {
    final Window window = getWindow();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        if (enabled) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {/*from   w  ww  .  j a v a  2  s .  co  m*/
            window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        }
    } else {
        window.getDecorView().setSystemUiVisibility(enabled ? View.SYSTEM_UI_FLAG_FULLSCREEN : 0);
    }
}

From source file:org.kaaproject.kaa.demo.photoframe.activities.SlideshowActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setLightsOutMode(boolean enabled) {
    final Window window = getWindow();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        if (enabled) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {/*  w  w w . j  a  v  a 2s  .c  o m*/
            window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        }
    } else {
        window.getDecorView().setSystemUiVisibility(enabled ? View.SYSTEM_UI_FLAG_FULLSCREEN : 0);
    }
}

From source file:com.ycdyng.onemulti.MultiFragment.java

public void setStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mColorPrimaryDark != 0) {
        Window window = mActivity.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(mColorPrimaryDark);
    }/*from   w w  w.  j av a2s  .  c  o m*/
}

From source file:com.google.zxing.demo.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_zxing_capture);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(getResources().getColor(R.color.color_333333));
    }//from ww  w.j  a  v  a2s.  c  o  m
    zxingCaptureRlBack = (RelativeLayout) findViewById(R.id.zxing_capture_rl_back);
    zxingCaptureRlBack.setOnClickListener(this);
    zxingCaptureRlBack.setBackgroundResource(R.drawable.bg_common_btn);

    hasSurface = false;
    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

}