我在清单文件中声明了这个广播接收器:
<receiver android:name="classes.VoiceLaunchReceiver" >
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
当用户解锁并打开屏幕时,它会自动运行。在Jellybean 4.3及更低版本中,它可以完美运行。为什么它在Lollipop上无法正常工作?
(我已经知道系统会发送该意图,我想要的是使用我的接收器来检测它)
Intent.ACTION_USER_PRESENT
有一些注意事项:1) 它只会在用户解锁 Keyguard 时发送。如果他们没有锁屏,这个 intent 就不会被发送。2) 如果用户在启动前解锁设备,则只会发送给已注册的接收器。没有BroadcastReceiver
组件会被启动。 - alanv