1

I am doing an android applicaiton and I know its possible to show or hide the notification bar.

but is there a way to show it but Disable the ability to drag it down?

Thanks

Daniel Benedykt
  • 6,496
  • 12
  • 51
  • 73

2 Answers2

3

Well I think thats not possible, but you achieve something similar makin your activity FullScreen.

public class FullScreen extends Activity {
    @Override
    public 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.main);
    }
}

Jorgesys

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
1
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);


Log.d("Focus debug", "Focus changed !");

if(!hasFocus) {
Log.d("Focus debug", "Lost focus !");

Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
Ali Obeid
  • 141
  • 7
  • its would be nice if you could explain what this code what doing as well :) – MZaragoza May 01 '17 at 18:37
  • Sure! So this method is a system method same as onPause, onStart etc.. This method checks If the app lost the focus, if yes it will send an intent to the system to close any dialog above your application :) – Ali Obeid May 01 '17 at 19:15