How to Hide Status / Notification Bar while Service is running?

1k Views Asked by At

I have an app which place Overlay view in Home Screen implemented using service.. Now I want to hide Status/Notification Bar which displays time,battery and mobiletower icon. I've tried to hide the status bar using WindowManager.LayoutParams.FLAG_FULLSCREEN but it doesn't do anything . Full code of View Parameter is here:

In onCreate() method in Service class :

@Override
public void onCreate() {

    super.onCreate();
    inflater = LayoutInflater.from(this);
    oView = inflater.inflate(R.layout.main, null);

    gView = (GlowPadView) oView.findViewById(R.id.incomingCallWidget);
    gView.setPointsMultiplier(12);
    oView.setBackgroundColor(0x88ff0000);
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

    // oView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_FULLSCREEN
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                    | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    wm.addView(oView, params);
    oView.setOnTouchListener(this);
    gView.setOnTriggerListener(new OnTriggerListener() {

        @Override
        public void onTrigger(View v, int target) {
            // TODO Auto-generated method stub
            if (target == 0) {
                stopSelf();
            }
        }

        @Override
        public void onReleased(View v, int handle) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onGrabbedStateChange(View v, int handle) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onGrabbed(View v, int handle) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onFinishFinalAnimation() {
            // TODO Auto-generated method stub
        }
    });

Now I want only to hide status bar.. Any Help would be grateful......... Thanks in Advance....

0

There are 0 best solutions below