如何跳过的条件下的第一个活动第一个、条件下、跳过

2023-09-06 00:36:05 作者:最后一支舞

我要建一组应用程序作为类似于微软的Office套件。这里每个应用程序有它自己的发射,以及它可以从家庭应用程序内部启动。每个应用程序都有一个登录页面。我需要显示的登录页面时,应用程序从Android的发射装置,尚未出现登录页面,而在家里应用程序启动,我怎么能做到这一点?

I'm building a group of apps as a package similar to MS Office. Here each app has its own launcher as well as it can be launched from inside the home app. Each app has a login page. I need to display the login page when the app is launched from android launcher and not showing login page while launch from home app, How can i achieve this?

我的情况:

从启动----->(APP)登录页面--->(应用程序)主屏幕

From Launcher----->(App)Login page--->(App)Home screen

从主应用程序----->(应用程序)主屏幕

From Home app----->(App)Home screen

推荐答案

您可以做到这一点通过启动一个空的活动(无UI),并在其的OnCreate 方法取决于一些可变信息(可以使用的 共享preferences 可能用于这一目的),你可以决定哪些活动启动(登录或主屏幕应用程序)。

You can do that by launching an empty activity (with no UI) and in its OnCreate method depending on some variable information (You can use SharedPreferences perhaps for that purpose) you can decide which Activity to start (Login or Home Screen app).

PS:

顺便说一句,如果登录总是导致相同的活动(主屏幕,而不是用于登录其他地方),你甚至都不需要空的活动,你可以在的onCreate 登录活动的方法

Btw if the login always leads to the same activity (Home Screen and is not used to login somewhere else) you don't even need the empty activity, you can check this in the Oncreate method of the login activity

protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);

    if (logged_in_check_is_true)
       { 
          Intent intent = new Intent(this, HomeScreenActivity.class);
          this.startActivity (intent);
          this.finishActivity (0);
       }

    ...