List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:com.stockita.stockitapointofsales.utilities.Utility.java
/** * This method to will set the color of the statusbar to *///from ww w . j av a 2s .c o m public static void changeTheStatusbarColor(Activity activity, int colorResource) { /** * Change the color of the status bar */ Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (Build.VERSION.SDK_INT >= 23) { window.setStatusBarColor(ContextCompat.getColor(activity, colorResource)); } else { window.setStatusBarColor(activity.getResources().getColor(colorResource)); } }
From source file:Main.java
public static void setWindowBrightness(Activity activity, float screenBrightness) { float brightness = screenBrightness; if (screenBrightness < 1) { brightness = 1;//from ww w .ja v a 2 s . co m } else if (screenBrightness > 255) { brightness = screenBrightness % 255; if (brightness == 0) { brightness = 255; } } Window window = activity.getWindow(); WindowManager.LayoutParams localLayoutParams = window.getAttributes(); localLayoutParams.screenBrightness = (float) brightness / 255; window.setAttributes(localLayoutParams); }
From source file:jahirfiquitiva.iconshowcase.utilities.ThemeUtils.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void onActivityCreateSetNavBar(Activity activity) { final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity); int navBarState = 0; int mNavBar = sp.getInt("navBar", navBarState); switch (mNavBar) { default:/*from w ww .j a v a 2s. c o m*/ case NAV_BAR_DEFAULT: activity.getWindow().setNavigationBarColor( darkTheme ? ContextCompat.getColor(activity, R.color.dark_theme_primary_dark) : ContextCompat.getColor(activity, R.color.light_theme_primary_dark)); coloredNavBar = true; break; case NAV_BAR_BLACK: activity.getWindow().setNavigationBarColor( transparent ? ContextCompat.getColor(activity, R.color.home_clear_background) : ContextCompat.getColor(activity, android.R.color.black)); coloredNavBar = false; break; } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void setFlagSecure(Activity activity) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { // Prevent screenshots; FLAG_SECURE is restricted to HoneyComb and above to prevent issues with some Samsung handsets // Please see http://stackoverflow.com/questions/9822076/how-do-i-prevent-android-taking-a-screenshot-when-my-app-goes-to-the-background activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); }//from ww w . j a v a2 s. c om }
From source file:android.support.v7.app.AppCompatDelegate.java
/** * Create a {@link android.support.v7.app.AppCompatDelegate} to use with {@code activity}. * * @param callback An optional callback for AppCompat specific events *///from w w w . j a v a 2s.com public static AppCompatDelegate create(Activity activity, AppCompatCallback callback) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return new AppCompatDelegateImplV11(activity, activity.getWindow(), callback); } else { return new AppCompatDelegateImplV7(activity, activity.getWindow(), callback); } }
From source file:com.king.base.BaseActivity.java
public static View getContentView(Activity activity) { ViewGroup view = (ViewGroup) activity.getWindow().getDecorView(); FrameLayout content = (FrameLayout) view.findViewById(android.R.id.content); return content.getChildAt(0); }
From source file:org.kontalk.util.SystemUtils.java
public static void acquireScreenOn(Activity activity) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:org.kontalk.util.SystemUtils.java
public static void releaseScreenOn(Activity activity) { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * shot the current screen ,with the status and navigationbar* *///from w ww. j ava 2s . co m public static Bitmap ShotActivity$WithoutStatus$WithoutNavigationBar(Activity ctx) { int statusH = getStatusH(ctx); int navigationBarH = getNavigationBarHeight(ctx); View view = ctx.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bp = Bitmap.createBitmap(view.getDrawingCache(), 0, statusH, view.getMeasuredWidth(), view.getMeasuredHeight() - statusH - navigationBarH); view.setDrawingCacheEnabled(false); view.destroyDrawingCache(); return bp; }
From source file:Main.java
public static void hideKeyBoard(final Activity activity) { if (activity == null) return;/*from ww w .jav a 2 s . c om*/ activity.runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub InputMethodManager mgr = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); } }); }