来源: android 锁屏(二) – 老牛比 – CSDN博客
这篇呢,我们讲程序的入口。
SAFScreenReceiver.Java :作为锁屏模块的入口。通过获取开机 和 锁屏键的广播,根据SAFScreenReceiver中存储是否允许锁屏,允许则启动锁屏服务
- package saf.cmcc.home.lock;
- import Android.content.BroadcastReceiver;
- import Android.content.Context;
- import android.content.Intent;
- import android.util.Log;
- /**
- * this class role is to receiver the system broadcast:open phone
- * @author issuser
- *
- */
- public class SAFScreenReceiver extends BroadcastReceiver {
- private static final String TAG = “SAFScreenReceiver”;
- @Override
- public void onReceive(Context context,Intent intent) {
- String action = intent.getAction();
- if(Intent.ACTION_BOOT_COMPLETED.equalsIgnoreCase(action)
- || Intent.ACTION_USER_PRESENT.equalsIgnoreCase(action)){
- Log.v(TAG, “action:”+action);
- SAFLockConstants.loadInitParam(context);
- if(SAFLockConstants.LOCK_ENABLE){
- Intent i = new Intent(context, SAFLockService.class);
- context.startService(i);
- }
- }
- }
- }
抱歉,没注释,不知道要写什么的。凑合看着吧