如何启动登录活动,如果用户不活跃的5分钟: [英] How to start Login Activity if user wasn't active for 5 minutes:

查看:144
本文介绍了如何启动登录活动,如果用户不活跃的5分钟:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开始在日志中活动如果用户并不活跃在应用5分钟
,未经哪些活动考虑到他离开该应用程序。 (由不活跃5分钟,我的意思是用户没有提交到服务器端的任何动作)

I need to start the log in Activity if the user wasn't active for 5 minutes in the application ,without considering from what activity he left the application. (by not active for 5 minutes I mean that the user didn't commit any action to the server side)

我有一个日期变量我的应用程序里面类:

private Date timeOfLogin;

当用户提交中的日志的保存,在使用中的某些点上用户可以得到一个电话或
邮件和将离开该应用程序。现在,这可能发生在应用程序的任何屏幕上。而现在,当他打开应用程序再次/返回到它完成他的电话后,我需要再次,而不是他的最后一次活动显示登录屏幕,如果5分钟或更长时间过去了。

that's is saved when the user commits log in, in some point of usage the user can get a phone call or a mail and will leave the application. now this can happen on any screen of the application. And now when he turns on the application again /return to it after finishing his phone call I need to show the log in screen again and not his last activity if 5 or more minutes have passed.

如何能不能做到?我必须覆盖每个 onResume 每个活动我的应用程序,并在活动启动日志如果差在 timeOfLogin 和当前日期间较大然后在5分钟呢?还是有更好的方式来做到这一点?

How can it be done? do I have to override every onResume of each activity I have in the application and start the log in Activity if the difference between the timeOfLogin and current date is bigger then 5 minutes? or is there a better way to do that?

任何帮助将是AP preciated。

Any help would be appreciated.

感谢。

推荐答案

还有一个活动,您的所有其他活动的延伸,把逻辑在该活动的onResume。 (您可能会发现这种做法是在很多其他方面也是有用的)

Have an activity that all of your other activities extend and put the logic in that activity's onResume. (You'll probably find this practice to be useful in a lot of other ways too)

这篇关于如何启动登录活动,如果用户不活跃的5分钟:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆