androidandroid-fragmentsandroid-activityonresume

Close app when minimized


I have similar problem like this.

On start my app displays a splash screen and checks via network if the current user is still premium.

My problem: I started my app right before I went to bed and minimized it by pressing the home button. In the morning I launched the app again and it resumed the activity from the night. The app never really quit, my splash screen was not shown and and it couldn't check if the user is still premium.

So how can I achieve my app to be closed after a certain time (e.g. when the app is minimized)?

But the problem is there is a portion in the app where I can view videos in full screen and here I use android's default player. So when the app is minimized while watching and then again open the app onResume will not be called and cannot check whether it is a registered user or not. The video player will continue to play the video. Is there any method so that I can kill the app when the video is playing and minimised?? is there any method which is called when the app is minimised using home key press?? Is it possible in every device to detect the home keypress event and write some code there?? Please help with some fresh ideas!!!


Solution

  • Dan Hulme in the comments above is right - I just want to use the app lifecycle correctly. I want to use onRestart not onResume. And that have done the work for me.