简体   繁体   English

Android:禁用向下滑动并查看wifi/飞行模式

[英]Android : disable swipe down and view wifi/airplane mode

How can I disable users can swipe down the title/notification bar as seen in the picture below.如何禁用用户可以向下滑动标题/通知栏,如下图所示。 I want my app run in kiosk mode and my users must not be able to swipe down or anything else.我希望我的应用程序在 kiosk 模式下运行,并且我的用户不能向下滑动或其他任何操作。

I tried using setting some flags but all I get is some kind of kiosk mode but users can still view the wifi/airplane etc screen on swipe down.我尝试使用设置一些标志,但我得到的只是某种信息亭模式,但用户仍然可以在向下滑动时查看 wifi/飞机等屏幕。

Please help, I can not find a good answer on Stackoverflow请帮忙,我在 Stackoverflow 上找不到好的答案

I don not want my users can see the screen below.我不希望我的用户看到下面的屏幕。

在此处输入图像描述

Refer to this answer here 在此处参考此答案

or或者

 private void disablePullNotificationTouch() {
            WindowManager manager = ((WindowManager) getApplicationContext()
                    .getSystemService(Context.WINDOW_SERVICE));
            WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
            localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
            localLayoutParams.gravity = Gravity.TOP;
            localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |

                    // this is to enable the notification to recieve touch events
                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |

                    // Draws over status bar
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

            localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
            localLayoutParams.height = (int) (25 * getResources()
                    .getDisplayMetrics().scaledDensity);
            localLayoutParams.format = PixelFormat.RGBX_8888;
            customViewGroup view = new customViewGroup(this);
            manager.addView(view, localLayoutParams);
        }

//Add this class in your project
public class customViewGroup extends ViewGroup {

    public customViewGroup(Context context) {
        super(context);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {

        Log.v("customViewGroup", "**********Intercepted");
        return true;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM