I'm trying to find a way to make my app launch an activity when a phone is unlocked/turned on after X time (15 minutes for example). I've been jotting ideas down and trying to find a way with no major errors.
I tried an IF command using
public void onReceive(Context context, Intent intent){
KeyguardManager keyguardManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
if (!keyguardManager.isKeyguardSecure()){
Intent startup = new Intent(MainActivity.this, NextActivity.class);}
But the NextActivity gets re-opened immediately whenever closed. I haven't tried the timer addition yet because I've been stuck on this part for about 2 days but any advice going into it would be appreciated.
Also I'm going to add an If command before this command to check if the device even has a security lock, and if it doesn't the code will check to see if the screen is on, but I haven't gotten that far yet.
Sorry If I'm not clear on what I need help on, only ever browsed this website.