Mobile unity | Check if screen is active or nor

I am creating an alarm app and i want the alarm to ring only if the screen is active( i.e when we are using it in someway)
Is there a way to do this in unity

PS: Is there a way for a app to check if a specific app is running in the background
Thank you

Is your alarm app using 3D rendering or complex 2d rendering?

If the answer is no, don’t use Unity for that.

If the answer is yes, in Unity “Project settings → Player” unckeck “Run in background”, so you will be sure it the alarm can start only when the Unity app is in foreground. Also see Application.isFocused.

Are you targeting Android or iOS or both?

It is for Android and your reply was help

I want the alarm to ring if the phone is being used

The reason for this specific requirement is I want my alarm to ring only if I am using my phone to remind to sleep and not ring if the phone is not being used

Is there a way to do this