Android 4.2 禁止下拉状态栏
最近在做一个界面需要禁止下拉状态栏,于是整理了一下,以后备用。
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 12.0 锁屏页面禁止下拉状态栏
目录 1.概述 2.锁屏页面禁止下拉状态栏的核心类 3.锁屏页面禁止下拉状态栏的核心功能分析和实现
- android10 禁止下拉状态栏
需求:android10 禁止下拉状态栏,也就是禁止下拉如下图的快速设置面板( Quick settings panel,也叫QS面板) 修改后:怎么拉都拉不下来,包括锁屏页面和正常桌面都无法下拉状态 ...
- android 4.4 禁止下拉,Android开发中禁止下拉式的实现技巧
我们开发项目的时候,经常会看到禁止的情况,而Android开发中并没有直接调用的接口,下面是爱站技术频道小编就给大家介绍的Android开发中禁止下拉式的实现技巧,希望网友们喜欢! 分享给大家供大家参 ...
- Android 9.0 SystemUI 下拉状态栏快捷开关
SystemUI 下拉状态栏快捷开关是 QSPanel,qs_panel.xml,@+id/quick_settings_panel,本篇文章就来看看这些快捷开关是如何呈现的以及如何新增一个快捷开关? ...
- Android 10.0 SystemUI下拉状态栏时间格式的修改(一)
在原生的下拉状态栏时间格式为 某月某日周几 这样的格式 客户需要修改为年月日周几 某时某分这种格式 这就需要修改 显示时间的格式 在更新时间时 按照这个格式更新就可以了 首选来看 时间控件的布局文件q ...
- Android 10.0 SystemUI下拉状态栏UI定制化开发系列(一)
1.概述 10.0定制化开发中,由于客户需求要求对整个SystemUI下拉状态栏和下拉通知栏部分的UI做定制,所以需要修改整个下拉状态栏的 UI布局页面,这要求对整个NotificationPanel ...
- Android 8.0 SystemUI下拉状态栏快捷开关
基于工作需要,基本是在Android源生代码上进行开发,从android 5.0到现在8.0,这两年碰到各种问题发现关于Android源生发开方面的特别少.于是想着开始把遇到的.解决的问题写下来,或许 ...
- Monkey测试时禁止下拉状态栏
Monkey 测试,随机点击.会下拉状态栏,关闭WiFi,打开GPS,打开蓝牙,打开飞行模式等一系列操作,严重干扰程序的测试,尤其是对网络状态下的耗电量测试. 下面的命令可以禁止 Monkey测试下, ...
- Android 10.0 SystemUI下拉状态栏UI定制化开发系列(八)
目录 1.概述 2.核心代码部分 3.核心代码分析 3.1状态栏黑色透明背景的分析
最新文章
- 【Python算法】哈希存储、哈希表、散列表原理
- 20145321 《Java程序设计》第7周学习总结
- android中可以使用bitmap的平铺,镜像平铺等减小图片带来的apk过大的问题
- Java技术分享:小白如何入门Mybatis?
- 阶段总结——201511
- 花了一天精选了20多篇好文,只为与你分享
- [No0000D6]端口-进程查询.bat
- 我的世界服务器怎么弄无限急迫,我的世界有什么指令设置无限急迫
- cart算法_ID3、C4.5、CART决策树算法
- android 检测摇一摇
- 同一个项目的同一DLL多版本的兼容问题
- altium designer 2019安装教程
- C++通过CMD修改电脑IP地址
- oracle访问emp表,通过deptno查询Emp表中雇员信息(oracle)
- SGX 是什么技术?
- Hdu-5919 Sequence II(主席树在线求区间不同数)
- Python入门篇(二)
- Universal DEP/ASLR bypass with msvcr71.dll and mona.py
- 移动硬盘识别为本地硬盘_如果仅在硬盘已经旋转时才能识别硬盘,该怎么办?
- Android 内置google dialer后发现拨号后,没有通话界面显示。