简体   繁体   中英

Confusion over execution order

I have a game application made up of several different activities. The first to be called is a splash screen, when this completes, this finishes and starts up another activity via an intent. In order to have access to some global data that is consistent across all the activities, I also have a "globals" class like this:

public class Globals extends Application
{
  int global_variable_A;
  int global_variable_B;
  int global_variable_C;

  public void onCreate()
  {
    // stuff
  }
}

In the androidmanifest.xml I have the the following (amongst other things):

<application
    android:icon="@drawable/mygame_icon"
    android:screenOrientation="portrait"
    android:label='"My Game"' android:name=".Globals">

<activity
    android:label="My Game"
    android:name=".Splash" 
    android:screenOrientation="portrait">
    <intent-filter >
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

My question now is, which will be executed first, the onCreate of Globals or the onCreate of Splash? Or are they run at the same time on different threads? I ask because I'm getting some inconsistent behaviour that would be explained if they were on different threads.

onCreate()全局偏离路线。首先执行应用程序,然后执行Activity,您可以通过在Application onCreate()方法中保留调试点来进行自我测试。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM