我正在使用android studio,我想知道是否有办法制作一个每次打开屏幕时都运行的应用程序(例如屏幕锁定)。我知道以前有人问过这个问题,但我不明白该把代码放在哪里..请帮忙
问问题
137 次
1 回答
0
<!-- SCREEN_ON BroadCast intent-filter -->
< receiver android: name = ".broadcast.LockScreenReceiver" >
< intent - filter >
< action android: name = "android.intent.action.SCREEN_ON" / >
< action android: name = "android.intent.action.SCREEN_OFF" / >
< action android: name = "android.intent.action.USER_PRESENT" / >
< /intent-filter>
</receiver >
//receive broadcast and do something
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
Log.e("scrennOn", "I'm comming!");
}
}
于 2015-08-22T16:00:46.683 回答