转自:http://blog.csdn.net/muskmelon123/article/details/7522023


package com.lock.muskmelon;import java.util.Timer;import java.util.TimerTask;import android.app.Activity;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.util.Log;public class Lock8secondActivity extends Activity {public void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.main);           final String TAG = null;        final IntentFilter filter = new IntentFilter();          filter.addAction(Intent.ACTION_SCREEN_OFF);          filter.addAction(Intent.ACTION_SCREEN_ON);         filter.addAction(Intent.ACTION_USER_PRESENT);                   final BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() {              @Override              public void onReceive(final Context context, final Intent intent) {                            String action = intent.getAction();                                 if(Intent.ACTION_SCREEN_ON.equals(action))               {                      Log.d(TAG, "screen is on...");                                }                              else if(Intent.ACTION_SCREEN_OFF.equals(action))               {                      Log.d(TAG, "screen is off...");                 }                                else if(Intent.ACTION_USER_PRESENT.equals(action))               {               Log.d(TAG, "screen is unlock...");                }                           }          };                  registerReceiver(mBatInfoReceiver, filter);}   } 


更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android 获取设备真实ip地址
  2. anroid 7.1添加自定义api服务
  3. Android圆角自定义View
  4. Android调试工具 —— TraceView [整理]
  5. Writing code that captures videos on A
  6. Android中使用HttpURLConnection和HttpCl
  7. android 5.0之后利用Intent传递Serializa
  8. Android面试宝典2020-持续更新
  9. Android(安卓)编译SurfaceFlinger测试程
  10. Android五种隐藏状态栏和标题栏的方法