Android的 - 检测应用程序的启动从家里或历史应用程序、家里、历史、Android

2023-09-12 22:06:27 作者:乱了分寸的心动"

什么是检测当一个Android的应用程序已经启动,从主屏幕/历史画面的最佳方法是什么?

基本上,我想要做到的,是强制用户每次回来的应用程序时登录到特定的屏幕(即他们可以完全访问所有活动一次登录,但基本上我希望他们能够重新验证当他们回来的应用程序,通过启动主屏幕上)。

我知道类似的问题已经被问过(即如何登录一个应用程序的启动) - 但没有,我已经看到了至今还没人能解决我的问题。所有的想法表示欢迎...

干杯,

解决方案   

什么是检测当一个Android的应用程序已经启动,从主屏幕/历史画面的最佳方法是什么?

您不能,AFAIK。

  

基本上,我想要做到的,是强制用户每次回来的应用程序时登录到特定的屏幕(即他们可以完全访问所有活动一次登录,但基本上我希望他们能够重新验证当他们回来的应用程序,通过启动主屏幕上)。

请使用一个明智的,人性化的登录系统。例如,如果你觉得自己的登录凭据陈旧基于时间,然后迫使他们重新登录。您可以通过检查凭证的onCreate(),如果是旧文件,调用 startActivity()要做到这一点启动您登录活动(或弹出的登录对话框,或任何你登录他们的方​​式)。

当然,一个更好的办法是跳过登录完全。除非这是一个密码安全,一个银行应用程序,或需要高于平均水平的安全别的东西,你不需要他们登录,您的用户将获得恼火,如果他们觉得你登录的要求是不必要的。大多数移动应用并不需要身份验证。

强制基于他们是如何到达活动的登录是用户敌对。你是在告诉屈尊使用手机的东西比你的应用程序等,他们是二等公民的用户。

Android Studio SDK tools下载 安装 配置及应用程序运行 详细,亲测

What is the best way to detect when an Android "Application" has been launched from the Home screen/History screen?

Basically, what I'm trying to achieve is force the user to login to certain screens each time they come back to the app (i.e. they have full access to all activities once logged in, but essentially I want them to re-authenticate when they come back to the app via launching on the home screen).

I know similar questions have been asked before (i.e. how to log launches of an app) - but none that I have seen has yet been able to solve my problem. All ideas welcome...

Cheers,

解决方案

What is the best way to detect when an Android "Application" has been launched from the Home screen/History screen?

You can't, AFAIK.

Basically, what I'm trying to achieve is force the user to login to certain screens each time they come back to the app (i.e. they have full access to all activities once logged in, but essentially I want them to re-authenticate when they come back to the app via launching on the home screen).

Please use a sensible, user-friendly login system. For example, if you feel that their login credentials are stale based upon time, then force them to log in again. You can do this by checking the credentials in onCreate(), and if they are stale, call startActivity() to launch your login activity (or pop up your login dialog, or whatever is your means of logging them in).

Of course, an even better approach is to skip the login entirely. Unless this is a "password safe", a banking app, or something else that needs higher-than-average security, you do not need them to log in, and your users will get irritated if they feel that your login requirement is unnecessary. Most mobile applications do not require authentication.

Forcing a login based upon how they reached the activity is user-hostile. You are telling users that deign to use their phones for things other than your app that they are second-class citizens.