每次用户返回Android应用程序时都需要登录 [英] Require login every time user returns to Android application

查看:78
本文介绍了每次用户返回Android应用程序时都需要登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个处理敏感用户信息的Android应用.要求之一是,要求用户在离开应用程序并返回时再次登录.当用户按下主页"按钮然后重新启动应用程序时(在 AndroidManifest.xml <中的 Activity 上的 android:clearTaskOnLaunch 属性).但是,当用户长按主页"按钮,切换到另一个应用程序,然后再返回时,我们需要做同样的事情.

I am working on an Android app that deals with sensitive user information. One of the requirements is that the user is required to log back into the application whenever they leave it and come back. This is easily dealt with for the case when the user presses the Home button and then relaunches the app (android:clearTaskOnLaunch attribute on the Activity in AndroidManifest.xml). However, we need to do the same thing when the user long presses the Home button, switches to another application, then comes back.

我已经以我能想到的所有方式进行了研究,但仍未找到可行的解决方案.使用Android甚至可以做到这一点吗?

I have researched this every way that I can think of and have not found a workable solution. Is this even possible with Android?

回答时,请记住,这是我无法控制的业务要求.

When answering, please keep in mind that this is a business requirement which I have no control over.

推荐答案

好吧,昨天我遇到了同样的问题.这是我所做的,并且效果很好:

Well, I had the same problem yesterday. This is what I did and it works fine:

  1. AndroidManifest.xml
  2. 中的主要活动中添加了 android:launchMode ="singleTask"
  3. 打电话给我的老板说:好吧,这将需要很长时间……等等!
  4. 整晚去喝啤酒.

请澄清一下,我的主要活动只有一个按钮,上面写着登录"并启动登录页面.

Just to clarify, my main activity only has a button that says login and launches the login page.

这篇关于每次用户返回Android应用程序时都需要登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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