Toggle the notification bar in android -


I know that I can extend the notification bar by reflection

  class & Lt ;? & Gt; Situation Manager = Class. ForName ("android.app.StatusBarManager"); Method shows; If (Build.VERSION.SDK_INT> = 17) {showb = statusbarManager.getMethod ("Detailed NotificationPanel"); } And {showb = statusbarManager.getMethod ("extension"); } Showb.invoke (getSystemService ("statusbar"));  

However, is there any way to expand it, if it collapses, and it has already been expanded, then erased it?

The toggle function for status management is Android Docs, but it does not work for me.

Edit

I am calling this function from within a bound service.

I think you may have the necessary permissions disappearing. Make sure you have EXPAND_STATUS_BAR permission in your Manifest.xml:

  & lt; Usage-permission Android: name = "android.permission.EXPAND_STATUS_BAR" />  

Look around, I found this code:

  object sbservice = getSystemService ("statusbar"); Class & lt ;? & Gt; Situation Manager = Class. ForName ("android.app.StatusBarManager"); Method showb = statusbarManager.getMethod ("extension"); Showb.invoke (sbservice);  

You can try it

Edit:

Actually to find out if it's down or not, see. Override the On-Fondo Focus () method in your activity with the code below:

In permissions:

  & lt; Usage-permission Android: name = "android.permission.EXPAND_STATUS_BAR" /> Override:  

Override:

  Override public null at @WindowFocusChanged (Boolean hefocus) {try (if (hypocus) {object service = getSystemService (" Statusbar "); Class of the & lt ;? & gt; Stystem Manager = Class. ForName (" android.app.StatusBarManager "); Method Fall = Status Bar Manager .getMethod (" Fall "); Collapse .setAccessible (True); Fall (Exclude) {} (prefix) {if (! HasFocus) {try {Object service = getSystemService ("statusbar"); Class & lt;? & Gt; position Editor Manager = class. ForName (" Android.app.StatusBarManager "); Method collapse = Status bar manager .getMethod ("collapse"); collapse .setAccessible (true); collapse invoke (service);} hold (exception e) {// TODO auto generated blocking block e.printStackTrace ();} Ex.printStackTrace ();}}}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -