android 检测 Home 键

尚硅谷课程【笔记】——大数据之Shell【一】 【【尚硅谷】Shell脚本从入门到实战】笔记 阅读详情
1
public boolean dispatchKeyEvent (KeyEvent event)

可以重写不同的 keyevent 处理,但是 Home 不会 dispatch 过来,这就让检测 Home 键变得困难了。

PhoneWindowManager 主要负责每个 activity 的 ui 刷新和部分事件的处理,其中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void launchHomeFromHotKey() {
         if (mKeyguardMediator.isShowingAndNotHidden()) {
             // don't launch home if keyguard showing
         } else if (!mHideLockScreen && mKeyguardMediator.isInputRestricted()) {
             // when in keyguard restricted mode, must first verify unlock
             // before launching home
             mKeyguardMediator.verifyUnlock( new OnKeyguardExitResult() {
                 public void onKeyguardExitResult( boolean success) {
                     if (success) {
                         try {
                             ActivityManagerNative.getDefault().stopAppSwitches();
                         } catch (RemoteException e) {
                         }
                         sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
                         startDockOrHome();
                     }
                 }
             });
         } else {
             // no keyguard stuff to worry about, just launch home!
             try {
                 ActivityManagerNative.getDefault().stopAppSwitches();
             } catch (RemoteException e) {
             }
             sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
             startDockOrHome();
         }
     }

其中:

1
2
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
startDockOrHome();

发送广播 Intent.ACTION_CLOSE_SYSTEM_DIALOGS,开始 Launch Home,根据这点,我们可以监听广播:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class InnerRecevier extends BroadcastReceiver {
  
         static final String SYSTEM_DIALOG_REASON_KEY = "reason" ;
  
         static final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions" ;
  
         static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps" ;
  
         static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey" ;
  
         @Override
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
             if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {   //监听广播
                 String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY); //获取原因
                 if (reason != null ) {
                     Lg.i( "receive action:" + action + ",reason:" + reason);
                     if (mListener != null ) {
                         if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) { // 按 Home
                             mListener.onHomePressed();
                         } else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { // 长按 Home
                             mListener.onHomeLongPressed();
                         }
                     }
                 }
             }
         }
  
     }

以下是完整代码:
package com.tiger.watcher;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;


import com.tiger.utils.Lg;


/**
 * watch the HOME key pressed, we only listen the HOME pressed <b>NOT Intercept
 * </b>this pressed.<br>
 * Tips:invoke {@link #startWatch()} in activity's onResume method and
 * {@link #stopWatch()} in activity's onStop Method.
 * 
 * @author idiottiger
 */
public class HomeWatcher {


    static final String LOG_TAG = "HomeWatcher";


    private Context mContext;


    private IntentFilter mFilter;


    private OnHomePressedListener mListener;


    private InnerRecevier mRecevier;


    public HomeWatcher(Context context) {
        mContext = context;
        mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    }


    /**
     * set the home pressed listener, if set will callback the home pressed
     * listener's method when home pressed.
     * 
     * @param listener
     */
    public void setOnHomePressedListener(OnHomePressedListener listener) {
        mListener = listener;
        mRecevier = new InnerRecevier();
    }


    /**
     * start watch
     */
    public void startWatch() {
        if (mRecevier != null) {
            mContext.registerReceiver(mRecevier, mFilter);
        }
    }


    /**
     * stop watch
     */
    public void stopWatch() {
        if (mRecevier != null) {
            mContext.unregisterReceiver(mRecevier);
        }
    }


    class InnerRecevier extends BroadcastReceiver {


        static final String SYSTEM_DIALOG_REASON_KEY = "reason";


        static final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";


        static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";


        static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";


        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
                String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
                if (reason != null) {
                    Lg.i("receive action:" + action + ",reason:" + reason);
                    if (mListener != null) {
                        if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
                            mListener.onHomePressed();
                        } else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
                            mListener.onHomeLongPressed();
                        }
                    }
                }
            }
        }


    }


}
最新Python爬虫实战(入门爬虫篇)——案例1:某瓣网站Top250图片数据采集(附上完整爬虫代码) 本次案例通过Python爬虫技术实现了某瓣Top250电影封面的批量下载。代码采用模块化设计,函数实现cookies的自动解析,简化了配置流程,涵盖请求、解析、存储的完整流程。学习重点包括:抓包工具定位数据源、正则表达式匹配图片链接、模拟请求头绕过反爬机制、以及自动化文件管理。需要注意控制请求频率并遵守网站使用规范,适用于入门爬虫实践。 阅读详情

相关推荐

告别TI官网迷路!手把手教你用C2000Ware为TMS320F28027搭建Proteus仿真工程模板

本文详细指导如何使用C2000Ware为TMS320F28027搭建Proteus仿真工程模板,帮助DSP开发者快速上手。从资源获取、工程目录设计到关键文件配置,再到CCS与Proteus的联调技巧,全面解析仿真工程搭建的每个步骤,特别适合初学者和工程师参考。

weixin_42715608的博客 472

个人第二个项目总结:home键,recent键,back键的屏蔽

我们都知道,android自5.0以后对一些属性有了比较大的改动,尤其是home键,在应用层已经无法做到屏蔽。今天就来看看如何屏蔽这三个键。 首先,因为不同手机的触发机制不一样,所以对于某些手机,recent键没法屏蔽,已知的有魅族,锤子(少数),鲁比亚(某些)。对于已知测试的手机,home键,back键都能屏蔽。 首先,屏蔽back比较简单,重写onKeyDown就可以了,直接上...

小男孩 6077

IMU卡尔曼滤波方法详细介绍

本文介绍了基于IMU和卡尔曼滤波的状态估计方法。系统采用9维状态向量(位置、速度、加速度计零偏),通过牛顿运动学建立状态方程,并利用外部位置观测进行校正。详细推导了状态转移矩阵和控制输入矩阵的形式,阐述了预测和更新的计算步骤。同时说明了过程噪声Q和观测噪声R的设置原则,其中Q反映模型不确定性,R取决于传感器精度。该方法可有效融合IMU测量与外部观测数据,实现位置、速度和偏置的联合估计。

haing2019的博客 757

按电源键屏幕唤醒和屏幕睡眠流程(从上层到kernel)

复制于http://blog.youkuaiyun.com/shadow_dance/article/details/8070252 粘贴如下: 一. 屏幕的唤醒       首先inputread在读取到有keyboard事件上报后,会调用到keydispatch的notifykey,去询问wm是否会对这次按键特殊处理,如果WM不处理,则此处会点亮或者熄灭屏幕。

xing176的专栏 1636

使用openMVS对样例数据进行重建

openMVS根据github上的步骤进行编译。注意,如果没有GPU,用不了CUDA的话,那么需要在openMVS目录下找到CmakeLists.txt文件,把CUDA设置为OFF: SET(OpenMVS_USE_CUDA OFF CACHE BOOL "Enable CUDA library") 可执行的文件生成在openMVS_build/bin/里面,在openMVS_build文件夹下打开终端,按照顺序执行如下命令即可逐步重建。其中,-w 设置的是数据的总路径,-i 后接输入的文件名,-o

YuhsiHu的博客 2887

记一次使用STM32F042K6芯片内部HSI48M时钟导致CAN总线报错问题

深入去解决某个问题时,也会加深你对其它部分的了解和思考,比如这里让我又重新了解和CAN的采样点和CAN报错机制。

ApexYuan 860

Android生命周期,点击home键和返回键时的顺序以及MENU菜单键简单测试

当一个程序执行的时候,启动的方法有 onCreate,onStart,onResume 当点击返回键时的全部顺序为: onCreate,onStart,onResume,点击返回键,onPause,onStop,onDestroy 再次启动程序时为点击返回键顺序为: onCreate,onStart,onResume,点击返回键,onPause,onStop,onDestroy

xiaoke804376088的博客 4005

【Unity学习笔记】事件系统EventSystem

1.EventSystem物体 第一次在Unity中创建UI元素时,总会自动生成一个EventSystem物体,它包含三个组件:Transform、EventSystem、Standalone Input Module。如果我们把它删除了,会发现UI上的事件(比如点击、拖拽)将不会被检测到。没错,它就是用来处理UI相关的事件的。 1.1 EventSystem组件 EventSystem基于输入给物体发送事件,它在整个事件系统中扮演的主要角色是: 1.管理被选中的物体 2.管理正在使用的Input Modu

一白梦人的博客 1万+

Android 4.4关机流程

基于Android 4.4得源码分析得。 最近有客户反馈Android得关机流程出现关机logo显示很久得问题,所有今天看下Android得关机流程(项目是基于4.4版本得) 长按power降会出现关机选择框源码在PhoneWindowManager.java中得interceptPowerKeyDown进行处理。 private void interceptPowerKeyDow...

linhaosheng123456的博客 786

手把手教你用微信小程序实现智能硬件音视频通话(含Linux/RTOS适配)

本文详细介绍了如何利用微信小程序硬件框架(WMPF)和音视频SDK,在智能硬件(包括Linux与RTOS设备)上实现音视频通话功能。文章从架构设计、设备端SDK集成、小程序VOIP插件开发到跨平台调试与性能优化,提供了全链路实战指南,帮助开发者打通微信小程序与嵌入式设备间的实时音视频通信。

ooo22的博客 329

uniapp - H5网页打包运行报错Failed to load resource: net::ERR_FILE_NOT_FOUND(uniApp打包成H5部署到服务器,打包h5白屏并报错页面空白)

Failed to load resource: net::ERR_FILE_NOT_FOUND,uniapp 坑之打包之后白屏,uniapp打包h5,HBuilderX 打包H5后空白报错 Failed to load resource: net::ERR FILE NOT_FOUND,UNI-APP H5应用白屏(空白页)解决方案,白屏并报错Failed to load resource: net::ERR_FILE_NOT_FOUND,uniapp开发,打包成H5部署到服务器,uniapp打包之后首页

🏆 前端领域优质创作者 3578

Android 长按电源键弹出的GlobalActions菜单

frameworks\base\core\res\res\values\config.xml 选择1会弹出Global actions menu。item的创建在LegacyGlobalActions里。

xiaowang_lj的博客 2112

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

android 判断按home键,如何检测用户在我的活动中按HOME键?

根据JM Lord的评论,这个答案可能无法满足Lollipop及以上设备的要求。请参阅Android L中的getRunningTasks替代方案虽然,这是一个老问题,但大多数答案在API级别17及以上版本中对我不起作用。我正在回答最终为我工作的事情。我尝试了很多方法,但没有一个像今天一样工作。我试过答案在Android上按下主页按钮时的调用方法,在android和中检测主页按钮按下覆盖主页按钮 ...

weixin_36076907的博客 654

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

android 判断按home键,android – 如何在我的活动中检测用户按HOME键?

更新[2015年8月]:根据JM Lord的评论,此答案可能无法按照设备Lollipop及以上的要求进行.见Alternative to getRunningTasks in Android L虽然,它的一个旧问题,但绝大多数的答案在我的API 17级及以上级别对我来说无效.我正在回答什么终于为我工作.我尝试了很多方法,但没有一个像今天一样工作.我试过答案这个要点是,家里就像一个紧急逃生按钮.所以...

weixin_29704001的博客 418

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Atitit.android js 的键盘按键检测Back键Home键和Menu键事件

Atitit.android js 的键盘按键检测Back键Home键和Menu键事件     1. onKeyDown @Override  public boolean onKeyDown(int keyCode, KeyEvent event) {      if (keyCode == KeyEvent.KEYCODE_MENU) {     // 在这里做你想做的事情

attilax的专栏 1822

android 判断is home,Android - See if home key is pressed

问题I'm making a game and if the activity is left in any way by the user (back or home key pressed), the activity needs to end the game by posting to a script and ending the activity.I can detect if the...

weixin_27956639的博客 187

监听android home键的实现方式

监听Home键一直困扰这大家,也是让大家非常纠结的问题,从我的博客点击量上看,就知道这个问题有多么难以解决。 此篇博客又来了一次修改,第一部分是解决2.2或者之前系统版本home的监听,第二部分是4.0.x的home监听 第一部分: 如果想监听home键,实现方式有几种 第一种方式:android 对home键的监听,加上了权限,必须取得对处理home键事件的权限,才能对home键进行操作

a1031359915的专栏 1118

Android framework 中双击 home 的实现

前言          欢迎大家我分享和推荐好用的代码段~~ 声明          欢迎转载,但请保留文章原始出处:          优快云:http://www.youkuaiyun.com          雨季o莫忧离:http://blog.youkuaiyun.com/luckkof 正文   如果你需要做双击 home key 的检测 你可以参考如下 sample co

奥特曼 2207

安卓开发教你监听手机Home键

在之前的开发过程中,发现手机home键和其它事件都用到了OnnewInte

cuihao1234的专栏 1158

Android framework中双击home 的实现

前言          欢迎大家我分享和推荐好用的代码段~~ 声明          欢迎转载,但请保留文章原始出处:          优快云:http://www.youkuaiyun.com          雨季o莫忧离:http://blog.youkuaiyun.com/luckkof 正文   如果你需要做双击 home key 的检测 你可以参考如下 sampl

旷野清泉-技术交流 953

android 点击home键事件,监听android home键的实现方式

public boolean onKeyDown(int keyCode, KeyEvent event) {if(KeyEvent.KEYCODE_HOME==keyCode){//写要执行的动作或者任务android.os.Process.killProcess(android.os.Process.myPid());}return super.onKeyDown(keyCode, event...

weixin_30430333的博客 346

android处理home键的方法

由于android4.0以上对于home键,不能屏蔽,所以只能监听home键做相应的处理: 首先注册监听: registerReceiver(mHomeKeyEvent, new IntentFilter( Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); 监听的实现: private BroadcastReceiver mHomeKeyEvent = ne

不积跬步,无以至千里 715

android4.2 拦截power键,Android 屏蔽Power键 Home键

2014-04-18 17:22 1557人阅读 评论(0) 收藏 举报 分类: Android(46) 版权声明:本文为博主原创文章,未经博主允许不得转载。最近正在处理工厂测试的功能,里面有个功能测试是前面板按键功能测试。需求中要求:在按每个前面板按键时,要修改UI中每个对应按键的颜色。其中有两个键Home键,和Power键,程序需要对这两个按键进行拦截,网上查了一些资料,现归纳一下常用的几...

weixin_36084686的博客 803
上一篇: android 9.png 图片制作
zen
zen
博客等级 码龄20年 18粉丝 7原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值