Android developed a method to disable the drop down notification bar
- 2021-01-18 06:38:28
- OfStack
This article illustrates the Android development approach to disallow the drop-down notification bar. To share with you for your reference, as follows:
1. Add permissions to AndroidManifest.xml
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
<uses-permission android:name="android.permission.STATUS_BAR"/>
2. Add in the corresponding activity
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
try {
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method test = statusbarManager.getMethod("collapse");
test.invoke(service);
} catch (Exception ex) {
ex.printStackTrace();
}
}
I hope this article is helpful to Android program design.