I need after clicking on the button that is attached to push notification so that the StatusBar minimized.
For this I found this method
private void expandStatusBar(Context context){ Log.e("!!!!!!!!!!!!!!!!!!!!", "!!!!!!!!!!!!!!!!!!!!! 2"); try { Log.e("!!!!!!!!!!!!!!!!!!!!", "!!!!!!!!!!!!!!!!!!!!! 3"); Object service = context.getSystemService("statusbar"); Class<?> statusBarManager = Class.forName("android.app.StatusBarManager"); if (Build.VERSION.SDK_INT <= 16) { Log.e("!!!!!!!!!!!!!!!!!!!!", "!!!!!!!!!!!!!!!!!!!!! 4"); Method collapse = statusBarManager.getMethod("collapse"); collapse.setAccessible(true); collapse.invoke(service); } else { Log.e("!!!!!!!!!!!!!!!!!!!!", "!!!!!!!!!!!!!!!!!!!!! 5"); Method collapse2 = statusBarManager.getMethod("collapsePanels"); collapse2.setAccessible(true); collapse2.invoke(service); } }catch(Exception ignored){} } I launch it immediately after the user presses the button:
mNotificationManager.cancel(0); Log.e("!!!!!!!!!!!!!!!!!!!!", "!!!!!!!!!!!!!!!!!!!!! 1"); expandStatusBar(context); new ModelViewer(context).openFileIfAvailable(); Tested and everything goes in the logs 1,2,3,4 , but the curtain does not fold ...
But in the code it emphasizes this line:
Object service = context.getSystemService("statusbar"); and says that the "statusbar" is not like that ... You need to choose from Context.smth_else and choose Context.NOTIFICATION_SERVICE , but it still does not work ...
I tried to do this:
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.sendBroadcast (it);
But it also does not work ...
Tell me, what am I doing wrong?
it is hacky:) Maybe it just does not work anymore. Three years ago it worked. Such tricks should be avoided. - Eugene Krivenja