如何在服务运行时隐藏状态/通知栏?

时间:2013-07-19 09:56:40

标签: android android-intent android-service android-custom-view android-overlay

我有一个应用程序,它使用服务实现主屏幕覆盖视图..现在我想隐藏显示时间,电池和移动电源图标的状态/通知栏。我试图使用WindowManager.LayoutParams.FLAG_FULLSCREEN隐藏状态栏,但它没有做任何事情。 View Parameter的完整代码在这里:

在Service类的onCreate()方法中:

@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
        }
    });

现在我只想隐藏状态栏..任何帮助都会感激不尽......... 在此先感谢....

0 个答案:

没有答案