在任何界面不用通过滑动下拉状态栏的实现方法:
private static Class<?> mStatusBarManagerClassType = null;
private static Method mExpandNotificationsMethod = null;
private static Class<?> getStatusBarManagerClass() throws ClassNotFoundException {
if (mStatusBarManagerClassType == null) {
mStatusBarManagerClassType = Class.forName("android.app.StatusBarManager");
}
return mStatusBarManagerClassType;
}
public static void openNotifications(Context context){
try{
if (getExpandNotificationsMethod() != null) {
Method method = getExpandNotificationsMethod();
method.invoke(context.getSystemService("statusbar"));
}
} catch(Exception ex) {
LogUtils.e(TAG, "expand notifications panel failed : ");
ex.printStackTrace();
}
}
通过调用openNotifications()函数可以实现直接下拉状态栏到功能。