Search code examples
androidandroid-activitylifecycleoncreateandroid-launcher

Some problems about Oncreate of Application and Activity in Android application


I have already written some Android application, but recently I find that I still not really know how an Android Application works. My problems are something about the AndroidManifest.xml, I want to know something about the life cycle of Android applications. In the AndroidManifest.xml, there is an Application label and there is a sub-label of activity. In the activity label, main activity of the application will be marked like this:

<activity android:theme="@*android:style/Theme.NoTitleBar" android:label="@string/app_name" android:name="com.sofesec.mainactivity" android:launchMode="singleTask" android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

This means that the class called "com.sofesec.mainactivity" is the main activity of the application, and it will get executed first. But there is a field called "android: name" in the label of application -- the parent lable of activity -- and the value of the field may be "com.sofesec.lcz.test". When the application starts, the "com.softsec.lcz.test" class will be executed as well. I don't know which class is executed first. This is something about life cycle of an android application. Thanks for giving me some help !

This is the code of my application here:

public class test extends Application {
    private final String TAG = "test";
    @Override
    public void onCreate() {
        super.onCreate();
        OriginalApplication oa = new OriginalApplication(this);
        oa.configApplicationEnv();
    }
}

Solution

  • Use below link to know in detail about activity life cycle and manifest file.

    Android activity life cycle - what are all these methods for?

    http://developer.android.com/guide/topics/manifest/manifest-intro.html