我正在使用Android工作室,我想知道是否有办法制作每次打开屏幕时运行的应用程序(例如屏幕锁定)。我知道之前已经问过这个问题,但是我无法理解在哪里放置代码。 请帮忙
答案 0 :(得分: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!");
}
}
&#13;