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 事件处理方法和表达式都严格绑 ...
随机推荐
- Ubuntu中通过SuperVisor添加守护进程
1. 用途 守护进程用于保持一个指定程序(dll)时刻保持运行.在命令行终端中通过dotnet run命令执行的程序,在退出命令行终端后,程序自动终止.添加守护进程后,即使终端退出,程序仍可后台执行. ...
- python-给微信好友自动发送天气预报和每日一句
周末在宿舍学习python,女朋友那突然下了倾盆大雨,在图书馆门口跟我抱怨好久.最近又在学习python,就想给女朋友写个小程序,每天早上将每天的天气预报通过微信发个她. 在本程序中,用到了几个重要的 ...
- [SQL][MS SQL]ID自增列从1开始重新排序
数据库中把ID自增长重置成1: 一般做法:(太麻烦) 复制表数据->删除原表.新建一张表->粘贴: 新方法: 数据库中:新建查询->复制.粘贴一下代码->修改表名,执行即可(先 ...
- ssh 使用技巧
参考:https://deepzz.com/post/how-to-setup-ssh-config.html SSH Config 那些你所知道和不知道的事 预览目录 配置项说明 相关技巧 管理多组 ...
- python_14 静态属性、类方法、静态方法;组合;继承
静态属性 在类中函数前加@property,在实例调用函数时无需加(),将函数属性封装,调用时看起来与数据属性类似 将函数封装成数据属性的形式,外部调用时看不到逻辑,静态属性可以访问实例属性也可以访问 ...
- html5 Sortable.js 拖拽排序源码分析
最近公司项目经常用到一个拖拽 Sortable.js插件,所以有空的时候看了 Sortable.js 源码,总共1300多行这样,写的挺完美的. 本帖属于原创,转载请出名出处. 官网http:// ...
- promise.then, setTimeout,await执行顺序问题
promise.then VS setTimeout 在chrome和node环境环境中均输出2, 3, 1, 先输出2没什么好说的,3和1顺序让人有些意外 原因: 有一个事件循环,但是任务队列可以有 ...
- mysql null 相关bug
select 1 = null 并不是预期的 False 而是 Null select 1 is null; 这样才会产生预期的 False select 1 not is null 这样写是 错误 ...
- JSP/Servlet基础
动态网页的技术 html+css javascript(弱语言) jquery(改造) jsp(java的html) servlet(核心) S2SH:structs2 (springmvc) spr ...
- vue-cli脚手架中webpack配置基础文件详解
一.前言 原文:https://segmentfault.com/a/1190000014804826 vue-cli是构建vue单页应用的脚手架,输入一串指定的命令行从而自动生成vue.js+wep ...