Reputation: 386
I wanted to know whether there is any way of knowing whether the notifications bar is open. I have the below code to open the notification bar from a program:
Object sbservice = getSystemService( "statusbar" );
Class<?> statusbarManager = Class.forName( "android.app.StatusBarManager" );
Method showsb;
if (Build.VERSION.SDK_INT >= 17) {
showsb = statusbarManager.getMethod("expandNotificationsPanel");
}
else {
showsb = statusbarManager.getMethod("expand");
}
showsb.invoke( sbservice );
Is there any way to know whether the panel is already open?
Upvotes: 3
Views: 1934
Reputation: 4462
Add the following to your Activity
:
@Override public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
// if hasFocus is false, notification panel is open.
}
Doco for this function is here.
Upvotes: 4