0
votes

I had an application with full screen, but when I display a popup window I lost the full screen behaviour, I cheek my application only in popup that I lost full screen,

this is my method of full screen :

   public void call(Activity activity) {
    if(Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
        View v = activity.getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else if(Build.VERSION.SDK_INT >= 19) {
        //for new api versions.
        View decorView = activity.getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }
}

I google it and I found in this post "only has effect when the view you call it from is visible"

So there's a solution ?

3

3 Answers

0
votes

You have to use SYSTEM_UI_FLAG_IMMERSIVE_STICKY for this case, see the official documentation for more details

Update

don't forget to add in your manifest.xml this

<activity android:name=".YourActivity" 
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
      />

:

0
votes

Try this:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);

}

UPDATE: Try this:

public void open(View view){

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setMessage("Are you sure,You wanted to make decision");



    alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() {

       @Override
       public void onClick(DialogInterface arg0, int arg1) {
          Toast.makeText(MainActivity.this,"You clicked yes button",Toast.LENGTH_LONG).show();
       }
    });

    alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() {
       @Override
       public void onClick(DialogInterface dialog, int which) {
          finish();
       }
    });

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
    alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    alertDialog.getWindow().getDecorView().setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
              | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
          | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_FULLSCREEN
          | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
          | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);


    alertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

 }
0
votes

This need to be done at onWindowFocusChanged, because popup window changes the window focus. This is how I do it:

override fun onWindowFocusChanged(hasFocus: Boolean) {
    super.onWindowFocusChanged(hasFocus)
    if (hasFocus && MyPref.getPref(PREF_FULLSCREEN, true)) {
        fullscreen()
    }
}