为什么我不能找到一个参考直接StatusBarManager类? [英] Why can't I find a reference to the StatusBarManager class directly?

查看:460
本文介绍了为什么我不能找到一个参考直接StatusBarManager类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要动态地在Android的通知区域拖累,唯一的解决办法是这样的

 对象sbservice = getSystemService(状态栏);
    类<> statusbarManager =的Class.forName(android.app.StatusBarManager);
    方法showsb = statusbarManager.getMethod(扩大);
    showsb.invoke(sbservice);
 

这奇妙的作品,但为什么污秽与反思?为什么我不能找到一个参考直接StatusBarManager类?为什么会出现没有在上下文类中的常量状态栏的服务?

解决方案
  

为什么与反思的龌龊?

由于它不是Android SDK的一部分。只关心创造不可靠的应用程序的人会尝试与交互的 StatusBarManager C本身的Andr​​oid源$ C ​​$,因为核心Android团队和设备制造商外,欢迎变革每当他们想的SDK以外的任何东西。

  

为什么我不能找到一个参考StatusBarManager类直接?

由于它不是Android SDK的一部分。这里有很多类和方法在Android框架类标有 @hide 注释,对于各种原因:不愿承诺无限支持的API安全通过隐藏,等等。

  

为什么会出现没有在Context类的状态栏的服务?

常数

由于它不是Android SDK的一部分。你肯定欢迎提供补丁到AOSP有 StatusBarManager 被提升到同一状态作为其他系统服务(例如, LocationManager NotificationManager )。如果 StatusBarManager 的情况只是一个疏忽后SDK是在〜2007年创建的,你的补丁很可能被接受,你会看到变化的Andr​​oid即将到来的版本。

To dynamically drag down notification area in Android, the only solution is this

    Object sbservice = getSystemService( "statusbar" );
    Class<?> statusbarManager = Class.forName( "android.app.StatusBarManager" );
    Method showsb = statusbarManager.getMethod( "expand" );
    showsb.invoke( sbservice );

This works wonderfully, but why the nastiness with reflection? Why can't I find a reference to the StatusBarManager class directly? Why is there not a constant in the Context class for the "statusbar" service?

解决方案

why the nastiness with reflection?

Because it is not part of the Android SDK. Only people interested in creating unreliable apps would try to interact with the StatusBarManager outside of the Android source code itself, since the core Android team and device manufacturers are welcome to change anything outside of the SDK whenever they wish.

Why can't I find a reference to the StatusBarManager class directly?

Because it is not part of the Android SDK. There are a great many classes and methods in Android framework classes that are marked with the @hide annotation, for all sorts of reasons: unwillingness to commit to support the API indefinitely, "security by obscurity", etc.

Why is there not a constant in the Context class for the "statusbar" service?

Because it is not part of the Android SDK. You are certainly welcome to supply patches to the AOSP to have StatusBarManager be "promoted" to the same status as the other system services (e.g., LocationManager, NotificationManager). If the StatusBarManager situation is merely an oversight after the SDK was created in ~2007, your patches might well be accepted and you would see the change in an upcoming version of Android.

这篇关于为什么我不能找到一个参考直接StatusBarManager类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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