魅族MX2 --点击notification收起 StatusBar

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mattdong0106/article/details/41745141

之前用的方法是:


try {
            Object statusBarManager = context.getSystemService("statusbar");
            Method collapse;

            if (Build.VERSION.SDK_INT <= 16) {
                collapse = statusBarManager.getClass().getMethod("collapse");
            } else {
                collapse = statusBarManager.getClass().getMethod("collapsePanels");
            }
            collapse.invoke(statusBarManager);
        } catch (Exception localException) {
            localException.printStackTrace();
        }
测试发现在魅族MX2上点击之后StatusBar并不能收起,最后发现用以下方法完美解决问题:

Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        context.sendBroadcast(it);


猜你喜欢

转载自blog.csdn.net/mattdong0106/article/details/41745141