我有一个服务,在其中我启动了一个警报,每当收到短信/电子邮件,但现在我想停止警报(如果它正在播放),一旦用户解锁屏幕。
为了提醒,我使用了MediaPlayer类。
请帮帮我。
谢谢
发布于 2011-02-08 20:44:23
如果您使用侦听android.intent.action.USER_PRESENT意图的BroadcastReceiver,您应该能够看到用户解锁屏幕的时间:
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
// Stop alert
}
}
registerReceiver(receiver, new IntentFilter(Intent.ACTION_USER_PRESENT));https://stackoverflow.com/questions/4931666
复制相似问题