创建一个每次打开屏幕时 运行 的应用

Creating an app that run everytime I turn the screen on

我正在使用 android studio,我想知道是否有办法让我每次打开屏幕(例如屏幕锁定)时都能 运行 制作一个应用程序。我知道之前有人问过这个问题,但我不明白将代码放在哪里...... 请帮忙

<!-- 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!");
    }
  }