How can I open the notification panel, as well as the quick settings that are above the notifications?
1 answer
Reflection comes to the rescue
Object sbservice = getSystemService( "statusbar" ); Class<?> statusbarManager = Class.forName( "android.app.StatusBarManager" ); Method showsb; if (Build.VERSION.SDK_INT >= 17) { showsb = statusbarManager.getMethod("expandSettingsPanel"); } else { showsb = statusbarManager.getMethod("expand"); } showsb.invoke( sbservice ); Manifest resolution
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> Explain
Starting from API 17, the expand method has been replaced with expandNotificationsPanel to open the notification panel and expandSettingsPanel to open quick settings.
Here is a list of all the StatusBarManager methods (API> = 17). So, for general development
collapsePanels //задвигает шторку disable //запретить выдвигать шторку. даже не пытайтесь. Метод требует разрешения STATUS_BAR, которое выдаётся только системным приложениям expandNotificationsPanel //открывает шторку уведомлений expandSettingsPanel //открывает быстрые настройки removeIcon //Используется системой для удаления значков на статусбаре setIcon //Используется системой для установки значков на статусбаре setIconVisibility //используется системой для установки видимости значков на статусбаре windowStateToString //возвращает состояние (скрыт, открыт, свернут) - I apologize if the question is stupid, but where can I get the sources of the StatusBarManager? - user235658
- grepcode.com/file/repo1.maven.org/maven2/org.robolectric/ ... or if you don’t want to mess around, I can add a reflection option to the answer - Flippy
- I have already tried 10 times, and could not do it ... Is it really that Google could not do it simply? - user235658
StatusBarManagercan not be supplied in the SDK for the reason that the developers of system software, it happens, it is written in different ways. - Flippy- Updated the answer. - Flippy
|
