需要帮助关闭我的Android应用 [英] Need help for closing my android app
问题描述
我开发一个Android应用程序。
我想放弃我的应用程序,但应用程序应该在后台运行状态。
每当我的应用程序单击应该从去年开始退出点。我不想再次登录。
I am developing an Android application. I want to quit my application but application should be in running state in background. Whenever I click on application application should start from last quit point. I dont want to login again.
当我preSS home键同样的事情正在发生。但我想我自己的按钮事件实现诸如Home键类似的功能。
我应该如何着手呢??
The same thing is happening when I press home button. But I want to implement similar functionality like Home button on my own button event. How should I proceed with that??
然而,尽管我已经完成了所有其他活动,我仍然需要重新登录。
当我完成了我的活动会话结束在那里。并在下次启动应用程序使用的登录屏幕。
But though I have finished all other activities, still I need to login again. When I finish the activity my session ends there. And on next app start with login screen.
而在家里点击按钮的情况下,它使我的会议,并在下次启动应用我的应用程序检查的地方我检查会话是否存在或不onResume()事件。如果会议是在那里我可以直接进入我的帐户。
Whereas in case of home button click, it keeps my session and on next app start my app check onResume() event where I am checking whether session exist or not. If session is there I can enter directly into my account.
因此,任何人有任何想法的android究竟做了什么,当我们preSS home键。
So Anybody have any idea what exactly android does when we press home button.
推荐答案
Android的设计是这样的:你不需要明确地终止您的应用程序时,系统会为你。
Android is designed this way: you don't need to explicitely terminate your applications, the system does it for you.
您只需要终止活动
或服务
致电 Activity.finish( )
或 Service.stopSelf()
来查看应用像你描述的行为。
You just have to terminate the Activities
or Services
by calling Activity.finish()
or Service.stopSelf()
to see your apps behaving as you described.
如果有任何登录过程,只是存储在共享preference
所需要的信息,使您的应用程序能够重新登录您或用在登录时获得的令牌(取决于过程的设计方式)。在共享preferences更多细节
的这里。
Should there be any log-in process, just store the needed information in a SharedPreference
to make your application able to re log-in for you or to use the token obtained at login time (depends of the way the process is designed). More details on SharedPreferences
here.
这篇关于需要帮助关闭我的Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!