On Android how can you detect when the user opens the system notification drawer? I've not found which calls are required to do this or even if it's possible? Does it cause a system notification I can monitor for?
Asked
Active
Viewed 422 times
2 Answers
1
I found the answer to my question in another SO question...
Disable the notification panel from being pulled down
It's a different issue but the ways for responding to changes in behaviour of the status bar/notification drawer is what I wanted. What I was looking for was responding to onWindowFocusChanged
as well adding the uses-permission
line to the manifest.
0
Try with this:
private ActionBarDrawerToggle mToggle;
private DrawerLayout drawer_layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
drawer_layout = (DrawerLayout)findViewById(R.id.your_drawer_layout);
mToggle = new ActionBarDrawerToggle(this, drawer_layout, "open", "close");
drawer_layout.addDrawerListener(mToggle);
mToggle.syncState();
// ...
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (mToggle.onOptionsItemSelected(item)) {
Log.d(TAG, "drawer opened");
}
return true;
}

Sergio
- 844
- 2
- 9
- 26
-
2I think he means the top level system notification bar. – DeeV Nov 01 '16 at 20:10
-
You are right, I made a mistake. I leave the answer just in case it is useful to someone. – Sergio Nov 01 '16 at 20:18
-
1Yes @Deev system notification bar. Thanks. I've edited the title and contents to denote this. Thanks for the response anyways Sergio. – Rob Segal Nov 01 '16 at 20:27