SystemUI中监听app启动,修改app中的状态栏背景色
参考 http://www.2cto.com/kf/201206/137225.html
从Android4.4开始,app可以自定义status bar 背景。 对于一些第三方app定义的状态栏背景,可以在系统源码中对其修改。
SystemUI是随着SystemUIService启动的,SystemUIService是常驻内存的,所以可以增加实时监听/观察功能。
PhoneStatusBar.java中 import android.app.IActivityManager;
import android.app.ActivityManagerNative;
import android.app.IActivityController; IActivityManager mAm; @Override
public void start() {
……
……
mAm = ActivityManagerNative.getDefault();
try {
mAm.setActivityController(new ActivityController());
} catch (RemoteException e) {
} } private class ActivityController extends IActivityController.Stub {
private boolean needUpdate = false;
public boolean activityStarting(Intent intent, String pkg) {
Log.d("antoon", "activityStarting, --> "+pkg);
if("com.android.mms".equals(pkg)){
mBgHandler.sendEmptyMessage(updateBg);
needUpdate = true;
}else if(needUpdate){
mBgHandler.sendEmptyMessage(rebackBg);
needUpdate = false;
}
return true;
} public boolean activityResuming(String pkg) {
Log.d("antoon", "activityResuming, --> "+pkg);
return true;
} public boolean appCrashed(String processName, int pid,
String shortMsg, String longMsg,
long timeMillis, String stackTrace) {
return false;
} public int appEarlyNotResponding(String processName, int pid, String annotation){
return 0;
} public int appNotResponding(String processName, int pid, String processStats) {
return 0;
} public int systemNotResponding(String msg){
return -1;
}
} private final int updateBg = 1;
private final int rebackBg = 2; private Handler mBgHandler = new Handler(){
public void handleMessage(Message msg) {
Log.d("antoon", "mBgHandler, ---, msg = "+msg);
switch (msg.what){
case updateBg:
mStatusBarView.setBackgroundColor(Color.BLUE);
break;
case rebackBg:
mStatusBarView.setBackgroundColor(R.color.system_bar_background_opaque);
break;
}
}
};
android\frameworks\base\core\java\android\app\IActivityController.aidl
/*
**
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/ package android.app; import android.content.Intent; /**
* Testing interface to monitor what is happening in the activity manager
* while tests are running. Not for normal application development.
* {@hide}
*/
interface IActivityController
{
/**
* The system is trying to start an activity. Return true to allow
* it to be started as normal, or false to cancel/reject this activity.
*/
boolean activityStarting(in Intent intent, String pkg); /**
* The system is trying to return to an activity. Return true to allow
* it to be resumed as normal, or false to cancel/reject this activity.
*/
boolean activityResuming(String pkg); /**
* An application process has crashed (in Java). Return true for the
* normal error recovery (app crash dialog) to occur, false to kill
* it immediately.
*/
boolean appCrashed(String processName, int pid,
String shortMsg, String longMsg,
long timeMillis, String stackTrace); /**
* Early call as soon as an ANR is detected.
*/
int appEarlyNotResponding(String processName, int pid, String annotation); /**
* An application process is not responding. Return 0 to show the "app
* not responding" dialog, 1 to continue waiting, or -1 to kill it
* immediately.
*/
int appNotResponding(String processName, int pid, String processStats); /**
* The system process watchdog has detected that the system seems to be
* hung. Return 1 to continue waiting, or -1 to let it continue with its
* normal kill.
*/
int systemNotResponding(String msg);
}
SystemUI中监听app启动,修改app中的状态栏背景色的更多相关文章
- wemall app商城源码Fragment中监听onKey事件
wemall-mobile是基于WeMall的android app商城,只需要在原商城目录下上传接口文件即可完成服务端的配置,客户端可定制修改.本文分享android开发Fragment中监听onK ...
- Windows平台下Oracle监听服务启动过程中日志输出
Windows平台下Oracle监听服务启动过程中日志输出记录. 日志目录:D:\app\Administrator\diag\tnslsnr\WIN-RU03CB21QGA\listener\tra ...
- win10家庭版 监听无法启动 报TNS-12560 TNS-00530
首先win10权限问题, 搜索设置->更新和安全 ->恢复->高级启动立即重启 疑难解答-高级选项-启动设置-重启-选择“4” 按“WIN+R”组合键,输入“control user ...
- 在Activity,Service,Window中监听Home键和返回键的一些思考,如何把事件传递出来的做法!
在Activity,Service,Window中监听Home键和返回键的一些思考,如何把事件传递出来的做法! 其实像按键的监听,我相信很多人都很熟练了,我肯定也不会说这些基础的东西,所以,前期,还是 ...
- Oracle监听已经启动了 sqlplus / as sysdba 仍然报 ERROR:ORA-12560
我的Oracle是11g的 system 的密码忘记了, 但是scott的密码我还记得而且能登录 . 想以sqlplus /as sysdba 修改system密码 一直在报 ERROR:ORA-12 ...
- Android-服务中监听电源键和Home键的广播、在锁屏下仍然工作的方法
Android-服务中监听电源键和Home键的广播 http://blog.csdn.net/u014657752/article/details/49512485 Android开发之如何监听让服 ...
- Fragment中监听onKey事件,没你想象的那么难。
项目中越来越多的用到Fragment,在用Fragment取代TabHost的时候遇到了一个问题,我们都知道,TabHost的Tab为Activity实例,有OnKey事件,但是Fragment中没有 ...
- hosts文件权限导致监听无法启动
1.所属系统:2.问题描述:3.解决4.参考???疑点:为什么修改主机名会使hosts文件权限发生改变 1.所属系统: ZHJS2#[/]uname -a HP-UX ZHJS2 B.11.31 U ...
- linux下oracle数据库服务和监听的启动停止
oracle数据库是重量级的,其管理非常复杂,将其在linux平台上的启动和关闭步骤整理一下. 安装完毕oracle以后,需要创建oracle系统用户,并在/home/oracle下面的.bash_p ...
- Vue 为什么在 HTML 中监听事件?
为什么在 HTML 中监听事件? 你可能注意到这种事件监听的方式违背了关注点分离(separation of concern)传统理念.不必担心,因为所有的 Vue.js 事件处理方法和表达式都严格绑 ...
随机推荐
- python 建立多维列表
今天用到在网上没有找到合适的思路,于是自己动手写了一个,作为记录. dpa = [] dpb = [] dpc = [] for i in range(21): dpa.append(0) for i ...
- mongoDB(2)--mongoDB的常用命令
默认设置后台启动: vi mongodb.cfg 创建配置文件,配置启动信息 dbpath=/root/mongodb/data logpath=/root/mongodb/log/mongodb.l ...
- 深入理解Java虚拟机读书笔记6----早期(编译期)优化
六 早期(编译期)优化 1 “编译期”的含义 · 可能是指一个前端编译器把*.java文件转变成*.class文件的过程,前端编译器如:Sun的Javac.Eclipse JDT中的增量式 ...
- JS sort() 方法
如果调用该方法时没有使用参数,将按字母顺序对数组中的元素进行排序,说得更精确点,是按照字符编码的顺序进行排序.要实现这一点,首先应把数组的元素都转换成字符串(如有必要),以便进行比较. array.s ...
- 10Linux_firewalld-Linux就该这么学
firewalld: runtime:当前生效,重启后失效(默认) permanent:当前不生效,重启后永久生效. A:重启,B:执行firewall-cmd --reload 数据链路层:ipta ...
- go 语言学习笔记(一)
本次学习目的:熟悉了解 go 语言特点,实现基本功能. 1.readfile.go package main import ( "bufio" "fmt" &q ...
- 整合MVC实现文件上传
1.整合MVC实现文件上传整合MVC实现文件上传在实际的开发中在实现文件上传的同时肯定还有其他信息需要保存到数据库,文件上传完毕之后需要将提交的基本信息插入数据库,那么我们来实现这个操作.整个MVC实 ...
- 深度学习原理与框架- batch_normalize(归一化操作)
1. batch_normalize(归一化操作),公式:传统的归一化公式 (number - mean) / std, mean表示均值, std表示标准差 而此时的公式是 scale * (num ...
- 给centos 7添加硬盘空间
前言 今天在安装ambari的时候,制作amberi本地yum源的时候出现了一个问题,虚拟机的磁盘空间不足了,后来发现是因为这个节点之前本来只打算作为数据节点使用的,后来所以后来只给它分配了20G的硬 ...
- 接口--Comparable接口【哈夫曼树】
我们在字符串中见到过CompareTo方法,知道这个方法是用于比较字符串顺序的,根据字典顺序进行排序.Java中很多类也都有CompareTo方法,甚至于排序算法的底层组成也是依赖于比较的,而这个比较 ...