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状态栏黑色透明背景的分析
最新文章
- dmidecode 命令详解(获取硬件信息)
- 上次谁说要简历模板来着?来!
- WEB前端学习一 JS预解释
- 使用c#操作IBM WebSphere MQ
- java hive demo_java 操作hive通过jdbc
- 4.3串的模式匹配算法(BF算法)
- 外媒:三星电子正与华为商讨芯片代工事宜
- 表单的管理作业及答案
- 秘笈|如何利用DNS做好网络安全工作
- 网吧局域网搭建(思科网络方案课程设计)
- keil5怎么放大字体_keil4调节字体 keil字体放大快捷键
- 安卓计算机切换用户,电脑模拟器小米游戏怎么切换账号
- GraphPad Prism 中文版 科研绘图工具
- 现代几何学在计算机科学中的应用,CNCC2017
- 傅里叶变换和小波变换:时间序列异常检测
- html用九张图片做出九宫图,用ps如何将九张照片做成九宫格?
- 英语单词记忆 词源法-思维导图(18)词源st/sist/stat/stin/stem-277
- 信息数据管理思维导图(Xmind)
- Matlab安装失败问题
- 【独立版】翻牌领红包系统一物一码仿口味王验证码抽奖码得红包追溯码源码程序无加密