参考 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. 虚拟机Ubuntu18.04——gcc版本的升降

    致读者:这是本人第一篇博客,小试牛刀,希望能在以后的道路中分享出更多实用的技巧和知识,大家一起进步. 操作环境: VMware Workstation 14Pro .64位Ubuntu18.04系统 ...

  2. python学习笔记----正则表达式

    正则: regular expression 常用的场景: #正则的包 >>> import re #match:开头匹配,匹配到,返回一个匹配对象,否则返回None >> ...

  3. pyqt5 -——菜单和工具栏

    一. 状态栏 # -*- coding: utf-8 -*-# @Time : 2018/12/22 12:37# @Author : Bo# @Email : mat_wu@163.com# @Fi ...

  4. 使用css设置三角形

    1.在开发中,有时候会用到一些小三角形来强调或者标记元素,这样以便区分不同的项目,然后把三角形绘制成一个比较明显的颜色,就达到效果了,那怎么才能画出三角形呢,之前我也不清楚,最近看到了有些网页在使用, ...

  5. 奇怪,Linux下find找不到文件了

    你遇到过linux下root用户执行find命令按文件名在根目录下查找不到指定文件的情况吗?如果你遇到这种情况,你分析可能有哪几种原因导致?这里记录一下这个有意思的问题. 问题现象 实现一个工具,需要 ...

  6. Python 学习笔记01篇

    编程基础很零碎 看了路飞学城的讲解视频,整体课程列表排列很清晰,每个视频都在十几分钟到二十几分钟之间,适合零碎化的的学习 第一章和第二章的前半部分可以较轻松地入门

  7. 使用pip安装包提示TLS证书错误解决办法

    最近有在使用pip安装python包的时候,总会出现以下类似的错误: Could not fetch URL https://pypi.python.org/simple/pytest-xdist/: ...

  8. ArcGIS案例教程-通过点坐标生成矩形

    ArcGIS案例教程-通过点坐标生成矩形 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 功能:以点坐标为中心,通过指定尺寸,生成矩形 成果形式:绿色工具,免安装,不 ...

  9. tensorflow_目标识别object_detection_api,RuntimeError: main thread is not in main loop,fig = plt.figure(frameon=False)_tkinter.TclError: no display name and no $DISPLAY environment variable

    最近在使用目标识别api,但是报错了: File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_o ...

  10. gitlab中批量删除本地以及远程tag的操作

    git 批量删除标签# 删除所有远程标签git show-ref --tag | awk '{print ":" $2}' | xargs git push origin # 删除 ...