最小化时关闭程序最小化、程序

2023-09-07 13:25:30 作者:岁月流逝、不再回首

在开始我的应用程序显示通过网络闪屏,并检查当前用户仍然premium。

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

我的问题:我开始了我的应用程序之前,我去睡觉和pressing home键最小化它。在早上,我再次推出的应用程序,它恢复从夜活动。该应用程序从未真正退出,并没有显示我的闪屏,并不能检查,如果用户仍然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)?

推荐答案

您应该写在 onResume()方法,以便premium用户检查逻辑如果活动处于暂停或背景状态下,它会检查它的逻辑将启动每次。

You should write the Premium user check logic in your onResume() method so that if the activity is in pause or background state it will check the logic every time it will be launched .