我不能展开状态栏没有我的Nexus 4与Android 4.2 [英] I can not expand statusbar no my nexus 4 with android 4.2

查看:251
本文介绍了我不能展开状态栏没有我的Nexus 4与Android 4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能展开状态栏没有我的Nexus 4采用Android 4.2,但其他级别运行OK,我的code是:

 公共无效OpenNotify(){
    // TODO自动生成方法存根
    INT currentApiVersion = android.os.Build.VERSION.SDK_INT;
    尝试{
        对象服务= getSystemService(状态栏);
        类<> statusbarManager =的Class.forName(android.app.StatusBarManager);        如果(服务!= NULL){
            / *方法扩大= service.getClass()statusbarManager.getMethod(扩大);
            expand.invoke(服务); * /
            如果(currentApiVersion< = 16){
                方法崩溃= statusbarManager.getMethod(崩溃);
                collapse.setAccessible(真);
                collapse.invoke(服务);
            }其他{
                方法collapse2 = statusbarManager.getMethod(collapsePanels);
                collapse2.setAccessible(真);
                collapse2.invoke(服务);
            }
        }    }赶上(例外五){
    }
}


    
我该怎么办?


解决方案

 公共无效OpenNotify(){
    // TODO自动生成方法存根
    INT currentApiVersion = android.os.Build.VERSION.SDK_INT;
    尝试{
        对象服务= getSystemService(状态栏);
        类<> statusbarManager =类
                .forName(android.app.StatusBarManager);
        方法扩大= NULL;
        如果(服务!= NULL){
            如果(currentApiVersion< = 16){
                扩大= statusbarManager.getMethod(扩大);
            }其他{
                扩大= statusbarManager
                        .getMethod(expandNotificationsPanel);
            }
            expand.setAccessible(真);
            expand.invoke(服务);
        }    }赶上(例外五){
    }}

在这种方式时,它运行确定!

I can not expand statusbar no my nexus 4 with android 4.2,but other level is running OK ,My code is:

public void OpenNotify() {
    // TODO Auto-generated method stub
    int currentApiVersion = android.os.Build.VERSION.SDK_INT;
    try {
        Object service  = getSystemService("statusbar");
        Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");

        if (service != null) {
            /*Method expand = service.getClass()statusbarManager.getMethod("expand");
            expand.invoke(service);*/
            if (currentApiVersion <= 16) {
                Method collapse = statusbarManager.getMethod("collapse");
                collapse.setAccessible(true);
                collapse.invoke(service);
            } else {
                Method collapse2 = statusbarManager.getMethod("collapsePanels");
                collapse2.setAccessible(true);
                collapse2.invoke(service);
            }
        }

    } catch (Exception e) {
    }


}

And

How can I do ?

解决方案

public void OpenNotify() {
    // TODO Auto-generated method stub
    int currentApiVersion = android.os.Build.VERSION.SDK_INT;
    try {
        Object service = getSystemService("statusbar");
        Class<?> statusbarManager = Class
                .forName("android.app.StatusBarManager");
        Method expand = null;
        if (service != null) {
            if (currentApiVersion <= 16) {
                expand = statusbarManager.getMethod("expand");
            } else {
                expand = statusbarManager
                        .getMethod("expandNotificationsPanel");
            }
            expand.setAccessible(true);
            expand.invoke(service);
        }

    } catch (Exception e) {
    }

}

In this way ,it runs OK !

这篇关于我不能展开状态栏没有我的Nexus 4与Android 4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆