List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:com.just.agentweb.VideoImpl.java
@Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity; if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return;/* ww w.j a v a 2 s. co m*/ } mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair = null; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (mMoiveView != null) { callback.onCustomViewHidden(); return; } if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (mMoiveParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); mMoiveParentView = new FrameLayout(mActivity); mMoiveParentView.setBackgroundColor(Color.BLACK); mDecorView.addView(mMoiveParentView); } this.mCallback = callback; mMoiveParentView.addView(this.mMoiveView = view); mMoiveParentView.setVisibility(View.VISIBLE); }
From source file:ti.modules.titanium.ui.android.AndroidModule.java
@Kroll.method public void hideSoftKeyboard() { getMainHandler().post(new Runnable() { @Override// ww w . j a v a2s .c om public void run() { Activity currentActivity = TiApplication.getAppCurrentActivity(); if (currentActivity != null) { TiUIHelper.showSoftKeyboard(currentActivity.getWindow().getDecorView(), false); } else if (activity != null) { TiUIHelper.showSoftKeyboard(getActivity().getWindow().getDecorView(), false); } else { Log.w(TAG, "Unable to hide soft keyboard. Activity is null", Log.DEBUG_MODE); } } }); }
From source file:me.wizos.loread.view.webview.VideoImpl.java
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { Activity mActivity; if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) { return;//w w w.j av a 2s .c o m } // ? mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Window mWindow = mActivity.getWindow(); Pair<Integer, Integer> mPair; // ???? if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mFlags.add(mPair); } if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) { mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0); mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mFlags.add(mPair); } if (videoView != null) { callback.onCustomViewHidden(); return; } // KLog.e("" + mWebView + " " + videoParentView); if (mWebView != null) { mWebView.setVisibility(View.GONE); } if (videoParentView == null) { FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView(); videoParentView = new FrameLayout(mActivity); videoParentView.setBackgroundColor(Color.BLACK); videoParentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // ? mDecorView.addView(videoParentView); } // KLog.e("" + mWebView.getVisibility() + " " + videoParentView); this.mCallback = callback; this.videoView = view; videoParentView.addView(videoView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); videoParentView.setVisibility(View.VISIBLE); isPlaying = true; }
From source file:com.RSMSA.policeApp.Dialogues.PaymentConfirmationDialogue.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); }
From source file:com.cranberrygame.phonegap.plugin.NavigationBar.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void _setUp(boolean autoHideNavigationBar) { if (autoHideNavigationBar) { Activity activity = cordova.getActivity(); //http://stackoverflow.com/questions/21164836/immersive-mode-navigation-becomes-sticky-after-volume-press-or-minimise-restore //http://www.youtube.com/watch?v=Xw9TIS_JsPM //https://developer.android.com/training/system-ui/status.html activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); final CordovaInterface cordova_final = cordova; //http://stackoverflow.com/questions/11762306/listen-for-first-touchevent-when-using-system-ui-flag-hide-navigation //http://stackoverflow.com/questions/15103339/android-full-screen-modeics-first-touch-shows-the-navigation-bar //http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html webView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override/* w ww . j ava2s . co m*/ public void onSystemUiVisibilityChange(int vis) { if (vis == 0) { //http://stackoverflow.com/questions/3072173/how-to-call-a-method-after-a-delay-in-android Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Activity activity = cordova_final.getActivity(); activity.getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }, 3000);//after ms } } }); } }
From source file:com.android.datetimepicker.date.DatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); }// w w w . j a v a 2 s. c om }
From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.CalendarDatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); }//from ww w .j a v a 2 s . c om }
From source file:com.facebook.react.modules.statusbar.StatusBarModule.java
@ReactMethod public void setHidden(final boolean hidden, final Promise res) { final Activity activity = getCurrentActivity(); if (activity == null) { res.reject(ERROR_NO_ACTIVITY, ERROR_NO_ACTIVITY_MESSAGE); return;//from ww w.j av a 2s . c o m } UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { if (hidden) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } res.resolve(null); } }); }
From source file:hide.com.android.datetimepicker.date.DatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); if (Utils.hasVibratePermission(activity)) { mVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); }/*from ww w. jav a 2 s. c o m*/ if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); } }
From source file:com.cranberrygame.cordova.plugin.navigationbar.NavigationBar.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void _setUp(boolean autoHideNavigationBar) { if (autoHideNavigationBar) { Activity activity = cordova.getActivity(); //http://stackoverflow.com/questions/21164836/immersive-mode-navigation-becomes-sticky-after-volume-press-or-minimise-restore //http://www.youtube.com/watch?v=Xw9TIS_JsPM //https://developer.android.com/training/system-ui/status.html activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); final CordovaInterface cordova_final = cordova; //http://stackoverflow.com/questions/11762306/listen-for-first-touchevent-when-using-system-ui-flag-hide-navigation //http://stackoverflow.com/questions/15103339/android-full-screen-modeics-first-touch-shows-the-navigation-bar //http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html //webView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener(){//cordova5 build error getView(webView).setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {//fixed cordova5 build error @Override//from w w w . j a v a 2s . c o m public void onSystemUiVisibilityChange(int vis) { if (vis == 0) { //http://stackoverflow.com/questions/3072173/how-to-call-a-method-after-a-delay-in-android Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Activity activity = cordova_final.getActivity(); activity.getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }, 3000);//after ms } } }); } }