检测滑动锁何时消失

时间:2013-10-16 11:26:13

标签: android lockscreen

我有一个服务,在锁定屏幕上显示一个浮动图标。我想在刷卡锁定并且出现安全锁定时立即隐藏浮动图标。目前,我正在收听Intent.ACTION_USER_PRESENT,但系统只会在安全锁发送时发送它!

1 个答案:

答案 0 :(得分:0)

您只需创建一个广播接收器即可采取行动:

<action android:name="android.intent.action.USER_PRESENT" />

广播接收器:

public class SwipeLockMonitorReceiver extends BroadcastReceiver {

@Override
public void onReceive(final Context context, Intent intent) {
    if (Intent.ACTION_USER_PRESENT.equalsIgnoreCase(intent
            .getAction())) {
        // Means the swipe lock gone.
    }
}

}

清单:

<receiver android:name="SwipeLockMonitorReceiver" >
        <intent-filter>
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>