我相信你正在寻找ACTION_USER_PRESENT意图行动.
public static final String ACTION_USER_PRESENT
从以下版本开始:API Level 3 Broadcast Action:在设备唤醒后用户出现时发送(例如,当键盘锁定消失时).
也就是说,Android目前不支持更换锁屏.市场上声称这样做的任何应用程序都会使用安全循环漏洞并且不安全.您可以阅读此主题以获取更多信息.(特别是,你应该阅读Mark Murphy的帖子).抱歉.
请参阅mylockforandroid的源代码, 您将需要使用DeviceAdminReceiver来禁用默认的android 屏幕锁定.
当用户解锁屏幕注册时启动您的活动,Intent.ACTION_SCREEN_ON并且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>
Run Code Online (Sandbox Code Playgroud)
并添加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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8214 次 |
| 最近记录: |