Android 4.2 禁止下拉状态栏
来源:互联网 发布:js实例子 编辑:程序博客网 时间:2024/05/10 22:13
最近在做一个界面需要禁止下拉状态栏,于是整理了一下,以后备用。
import android.app.StatusBarManager;//首先导入包
StatusBarManager mStatusBar = (StatusBarManager) getSystemService(this.STATUS_BAR_SERVICE);//获得对象
mStatusBar.disable(StatusBarManager.DISABLE_EXPAND);//禁止下拉状态栏
mStatusBar.disable(StatusBarManager.DISABLE_NONE);//启用下拉状态栏(在onDestroy()添加)
//此代码只能在源码环境下才能编译
---------------------------------------------------源码中是这样定义的--------------------------------------------------------
source/frameworks/base/core/java/android/app/StatusBarManager.java
public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND;
public static final int DISABLE_NONE = 0x00000000;
/**
* Disable some features in the status bar. Pass the bitwise-or of the DISABLE_* flags.
* To re-enable everything, pass {@link #DISABLE_NONE}.
*/
public void disable(int what) {
try {
final IStatusBarService svc = getService();//获得IStatusBarService 的对象
if (svc != null) {
svc.disable(what, mToken, mContext.getPackageName());//实际上使用的是IStatusBarService的disable方法
}
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
}
}
private synchronized IStatusBarService getService() {
if (mService == null) {
mService = IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));//使AIDL获取IStatusBarService对象
if (mService == null) {
Slog.w("StatusBarManager", "warning: no STATUS_BAR_SERVICE");
}
}
return mService;
}
source/frameworks/base/services/java/com/android/server/StatusBarManagerService.java
public void disable(int what, IBinder token, String pkg) {
disableInternal(mCurrentUserId, what, token, pkg);
}
private void disableInternal(int userId, int what, IBinder token, String pkg) {
enforceStatusBar();
synchronized (mLock) {
disableLocked(userId, what, token, pkg);
}
}
private void disableLocked(int userId, int what, IBinder token, String pkg) {
// It's important that the the callback and the call to mBar get done
// in the same order when multiple threads are calling this function
// so they are paired correctly. The messages on the handler will be
// handled in the order they were enqueued, but will be outside the lock.
manageDisableListLocked(userId, what, token, pkg);
final int net = gatherDisableActionsLocked(userId);
if (net != mDisabled) {
mDisabled = net;
mHandler.post(new Runnable() {
public void run() {
mNotificationCallbacks.onSetDisabled(net);
}
});
if (mBar != null) {
try {
mBar.disable(net);
} catch (RemoteException ex) {
}
}
}
}
source/frameworks/base/core/java/android/view/View.java
/**
* @hide
*
* NOTE: This flag may only be used in subtreeSystemUiVisibility. It is masked
* out of the public fields to keep the undefined bits out of the developer's way.
*
* Flag to make the status bar not expandable. Unless you also
* set {@link #STATUS_BAR_DISABLE_NOTIFICATION_ICONS}, new notifications will continue to show.
*/
public static final int STATUS_BAR_DISABLE_EXPAND = 0x00010000;
- Android 4.2 禁止下拉状态栏
- android禁止状态栏下拉
- android禁止下拉状态栏
- Android 禁止状态栏下拉
- Android禁止状态栏下拉 4.4
- Android 禁止系统状态栏下拉
- android在activity内禁止状态栏下拉
- Android 5.1系统禁止通知状态栏下拉
- Android状态栏禁止下拉异常分析
- SystemUI状态栏禁止下拉
- android 滑动锁屏状态下如何禁止下拉状态栏?
- android在activity中禁止下拉状态栏的方法
- android在activity中禁止下拉状态栏的方法
- Android 禁止下拉状态栏和底部导航栏的控制
- Android 禁止下拉状态栏和底部导航栏的控制
- Android5.0禁止状态栏下拉
- 禁止android显示状态栏
- [FAQ11621]KK 全屏界面禁止状态栏下拉
- Mantle的使用
- READING ARTICLE
- What is an LSN: Log Sequence Number
- Lesson 12 Life on a desert island
- Java通过浏览器请求头(User-Agent)获取 浏览器类型,操作系统类型,手机机型
- Android 4.2 禁止下拉状态栏
- nginx编译
- JVM程序员书单
- 英超联赛接口调用文档
- springmvc通过@Value注解读取Properties配置文件的值,junit测试可以取到值,但是在业务中无法读取
- Ckeditor调用示例
- operator bool(); operator const bool() const;
- Android--Dialog详细讲解
- Java,JavaScript中斜杠和反斜杠的替换