android 锁屏(二) - 老牛比 - CSDN博客

来源: android 锁屏(二) – 老牛比 – CSDN博客

这篇呢,我们讲程序的入口。

SAFScreenReceiver.Java :作为锁屏模块的入口。通过获取开机 和 锁屏键的广播,根据SAFScreenReceiver中存储是否允许锁屏,允许则启动锁屏服务

  1. package saf.cmcc.home.lock;
  2. import Android.content.BroadcastReceiver;
  3. import Android.content.Context;
  4. import Android.content.Intent;
  5. import android.util.Log;
  6. /**
  7.  * this class role is to receiver the system broadcast:open phone
  8.  * @author issuser
  9.  *
  10.  */
  11. public class SAFScreenReceiver extends BroadcastReceiver {
  12.     private static final String TAG = “SAFScreenReceiver”;
  13.     @Override
  14.     public void onReceive(Context context,Intent intent) {
  15.         String action = intent.getAction();
  16.         if(Intent.ACTION_BOOT_COMPLETED.equalsIgnoreCase(action)
  17.                 || Intent.ACTION_USER_PRESENT.equalsIgnoreCase(action)){
  18.             Log.v(TAG, “action:”+action);
  19.             SAFLockConstants.loadInitParam(context);
  20.             if(SAFLockConstants.LOCK_ENABLE){
  21.                 Intent i = new Intent(context, SAFLockService.class);
  22.                 context.startService(i);
  23.             }
  24.         }
  25.     }
  26. }

抱歉,没注释,不知道要写什么的。凑合看着吧

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏