我正在寻找编写一个 Android 应用程序,在有人正确输入默认的 Android 解锁模式后调用屏幕/活动。
我假设最好的方法是在后台运行一个服务来等待此活动,然后在检测到此活动时调用显示信息的活动屏幕?
这听起来是一种明智的做事方式还是有更好的方法?
另外,如果有人能给我指出这方面的例子,那就太棒了。
干杯
里克
I'm looking to write an android app that invokes a screen/activity after some one has entered the default android unlock pattern correctly.
I'm assuming that the best way to do this is run a service in the background that waits for this activity then on detecting this invokes an activity screen displaying the information?
Does that sound like a sensible way of doing things or is there a better way?
Also if anyone can point me at examples of this that would be amazing.
Cheers
Ric
发布评论
评论(2)
基本上,您需要为操作 BroadcastReceiver http://developer.android.com/reference/android/content/Intent.html#ACTION_USER_PRESENT" rel="nofollow">ACTION_USER_PRESENT
ACTION_USER_PRESENT
在ACTION_SCREEN_ON
之后触发,通常是在键盘保护消失时。因此,创建一个处理程序并等待
ACTION_USER_PRESENT
。当你得到它后,实施你想要的活动。Basically you need to register a BroadcastReceiver for the action ACTION_USER_PRESENT
ACTION_USER_PRESENT
is fired afterACTION_SCREEN_ON
, usually when the keyguard is gone.So create a handler and wait for
ACTION_USER_PRESENT
. When you got it, implement what you want for your activity.创建一个广播接收器来接收 boot_complete 操作,然后创建一个服务并从 BroadcastReceiver 的 onRecieve 启动它。
这里有一个很好的教程
Create a broadcast receiver to recieve boot_complete action then create a service and start it from onRecieve of broadcastReceiver .
A good tutorial here