gpt4 book ai didi

android - 为什么我不能直接找到对 StatusBarManager 类的引用?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:58:46 26 4
gpt4 key购买 nike

Android中要动态下拉通知区域,唯一的解决办法就是这个

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

这很好用,但为什么反射会很脏?为什么我不能直接找到对 StatusBarManager 类的引用?为什么“statusbar”服务的 Context 类中没有常量?

最佳答案

why the nastiness with reflection?

因为它不是 Android SDK 的一部分。只有对创建不可靠应用程序感兴趣的人才会尝试在 Android 源代码本身之外与 StatusBarManager 进行交互,因为欢迎核心 Android 团队和设备制造商随时更改 SDK 之外的任何内容。

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

因为它不是 Android SDK 的一部分。 Android 框架类中有很多类和方法都标有 @hide 注释,原因有很多:不愿意 promise 无限期地支持 API、“隐藏安全”等.

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

因为它不是 Android SDK 的一部分。当然,欢迎您为 AOSP 提供补丁,让 StatusBarManager 被“提升”到与其他系统服务(例如,LocationManagerNotificationManager)。如果 StatusBarManager 情况只是 SDK 在 ~2007 年创建后的疏忽,您的补丁很可能会被接受,并且您会在即将推出的 Android 版本中看到更改。

关于android - 为什么我不能直接找到对 StatusBarManager 类的引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11323637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com