请参阅mylockforandroid的源代码,
您将需要使用DeviceAdminReceiver来禁用默认的Android
屏幕锁。
当用户解锁屏幕将
Intent.ACTION_SCREEN_ONand 注册为时启动活动
Intent.ACTION_SCREEN_OFF:
将此代码添加到manifast.xml中,将ScreenReceiver注册为:
<receiver android:name=".ScreenReceiver"> <intent-filter> <action android:name="android.intent.action.SCREEN_OFF"/> <action android:name="android.intent.action.SCREEN_ON"/> </intent-filter> </receiver>
并将ScreenReceiver.java添加为:
public class ScreenReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { Intent intent = new Intent(); intent.setClass(context, ScreenLockActivity.class); startActivity(intent); } }}


