参考 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中的状态栏背景色的更多相关文章

  1. wemall app商城源码Fragment中监听onKey事件

    wemall-mobile是基于WeMall的android app商城,只需要在原商城目录下上传接口文件即可完成服务端的配置,客户端可定制修改.本文分享android开发Fragment中监听onK ...

  2. Windows平台下Oracle监听服务启动过程中日志输出

    Windows平台下Oracle监听服务启动过程中日志输出记录. 日志目录:D:\app\Administrator\diag\tnslsnr\WIN-RU03CB21QGA\listener\tra ...

  3. win10家庭版 监听无法启动 报TNS-12560 TNS-00530

    首先win10权限问题, 搜索设置->更新和安全 ->恢复->高级启动立即重启 疑难解答-高级选项-启动设置-重启-选择“4” 按“WIN+R”组合键,输入“control user ...

  4. 在Activity,Service,Window中监听Home键和返回键的一些思考,如何把事件传递出来的做法!

    在Activity,Service,Window中监听Home键和返回键的一些思考,如何把事件传递出来的做法! 其实像按键的监听,我相信很多人都很熟练了,我肯定也不会说这些基础的东西,所以,前期,还是 ...

  5. Oracle监听已经启动了 sqlplus / as sysdba 仍然报 ERROR:ORA-12560

    我的Oracle是11g的 system 的密码忘记了, 但是scott的密码我还记得而且能登录 . 想以sqlplus /as sysdba 修改system密码 一直在报 ERROR:ORA-12 ...

  6. Android-服务中监听电源键和Home键的广播、在锁屏下仍然工作的方法

    Android-服务中监听电源键和Home键的广播  http://blog.csdn.net/u014657752/article/details/49512485 Android开发之如何监听让服 ...

  7. Fragment中监听onKey事件,没你想象的那么难。

    项目中越来越多的用到Fragment,在用Fragment取代TabHost的时候遇到了一个问题,我们都知道,TabHost的Tab为Activity实例,有OnKey事件,但是Fragment中没有 ...

  8. hosts文件权限导致监听无法启动

    1.所属系统:2.问题描述:3.解决4.参考???疑点:为什么修改主机名会使hosts文件权限发生改变 1.所属系统: ZHJS2#[/]uname -a HP-UX ZHJS2 B.11.31 U ...

  9. linux下oracle数据库服务和监听的启动停止

    oracle数据库是重量级的,其管理非常复杂,将其在linux平台上的启动和关闭步骤整理一下. 安装完毕oracle以后,需要创建oracle系统用户,并在/home/oracle下面的.bash_p ...

  10. Vue 为什么在 HTML 中监听事件?

    为什么在 HTML 中监听事件? 你可能注意到这种事件监听的方式违背了关注点分离(separation of concern)传统理念.不必担心,因为所有的 Vue.js 事件处理方法和表达式都严格绑 ...

随机推荐

  1. orcal -学习准备

    格式化命令: 设置每行长度 SET LINESIZE 300; 设置每页长度 SET PAGESIZE 30; 使用文本编辑 文本编辑sql:ed aa 使用@aa 切换用户: CONN 用户名/密码 ...

  2. windows环境下安装rabbitmq及配置可视化管理界面

    1.环境 windows7 64位 rabbitmq3.7.9 erlang10.22.先安装erlang,后安装rabbitmq.下载地址: rabbitmq http://www.rabbitmq ...

  3. mysql添加外键无法成功的原因

    最近很忙,碰到很多问题都忘了发上来做个记录,现在又忘了,FUCK,现在碰到一个问题, 就是mysql添加外键总是无法成功,我什么都试了,就是没注意signed和unsigned,FUCK,因为我用my ...

  4. 使用Java的URL/HttpURLConnection进行远程调用(POST请求)

    利用Java的HttpURLConnection进行远程url请求(调用远程接口) 测试类:请求类型为json,以post方式请求,利用OutputStream写入数据 实体类: public cla ...

  5. leetcode答案 有效的括号(python)

    def isValid(s): if s and len(s) % 2 is 0: a = {')': '(', ']': '[', '}': '{'} l = [None] for i in s: ...

  6. PTA变成总结1

    1)实验代码 #include<stdio.h>int main(){ int N,k,n,i,j,p,m,ge; char op; while(1){  scanf("%d % ...

  7. API权限设计总结

    最近在做API的权限设计这一块,做一次权限设计的总结. 1. 假设我们需要访问的API接口是这样的:http://xxxx.com/openapi/v1/get/user/?key=xxxxx& ...

  8. webpack工程搭建

    >>建立nodejs工程 新建文件夹,npm init 生成package.json >>安装webpack 和 webpack-dev-server npm install ...

  9. Tomcat 配置MySQL连接池

    <!--配置mysql数据库的连接池,         需要做的额外步骤是将mysql的Java驱动类放到tomcat的lib目录下                maxIdle 连接池中最多可 ...

  10. python--第二十四天总结

    CMDB介绍 CMDB --Configuration Management Database 配置管理数据库, CMDB存储与管理企业IT架构中设备的各种配置信息,它与所有服务支持和服务交付流程都紧 ...