How To Detect Notification Center Is Pulled Down/up In Android
Since onPause and onResume is not called when the notification overlay is pulled down in Android L, is there a way for my Activity to update accordingly after the Notification Cent
Solution 1:
You can utilize your Activity's onWindowFocusChanged callback to detect when notification is pulled down/up while your Activity is running:
@OverridepublicvoidonWindowFocusChanged(boolean hasFocus) {
if (hasFocus) {
// notification is pulled up
} else {
// notification is pulled down
}
super.onWindowFocusChanged(hasFocus);
}
Solution 2:
I'm am afraid there is still no way to detect if the Notification Center is pulled pulled down.
You may want to reconsider if you need to implement a different behaviour when such an event occurs - maybe you'll find out it's not even necessary.
Solution 3:
You can add a receiver for the android.net.conn.CONNECTIVITY_CHANGE action. You'll be notified if the user changed the setting (but also for other types of network changes, so you'll need to handle these).
See docs here
Post a Comment for "How To Detect Notification Center Is Pulled Down/up In Android"