Is there a way to collapse notification bar on Android 4.2?
I use this code that works only for the previous Android versions:
try{
Object service = c.getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse.setAccessible(true);
collapse.invoke(service);
}catch(Exception ex){}
Please help me...
It's hacky but since you have decided to tread that path, try to use the following code.
if (currentApiVersion <= 16) {
Method collapse = statusbarManager.getMethod("collapse");
collapse.invoke(service);
} else {
Method collapse2 = statusbarManager.getMethod("collapsePanels");
collapse2.invoke(service);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With