Do you first execute the class for the name of the application or the class for name in the activity?

Source: Internet
Author: User

Today, we found the procedure entrance, and I've got two name, and I've written a test program, roughly as follows:

See Mainfest.xml first.

<application

Android:allowbackup= "true"
android:icon= "@drawable/ic_launcher"
Android:name= "Com.example.test1.app"
Android:label= "@string/app_name"
Android:theme= "@style/apptheme" >
<activity
Android:name= "Com.example.test1.MainActivity"
Android:label= "@string/app_name" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>


<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

</application>

K See app

Package com.example.test1;


Import android.app.Application;
Import Android.os.Bundle;
Import Android.util.Log;


public class App extends application{
public void OnCreate () {

Super.oncreate ();
LOG.D ("TT", "Application");
}


}


See activity as follows

public class Mainactivity extends Activity {


@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
LOG.D ("TT", "activity");
New app ();

}

Finally, we look at the log file is clear:

10-28 15:40:54.915:d/tt (4116): Application

10-28 15:40:55.525:d/tt (4116): Activity

This means that application's name corresponds to the class that was created when the program was installed .

Then I opened the second time as follows:


There is only one message

Android.app.Application
Base class for those who need to maintain global application state. You can provide your own implementation by specifying it name in your androidmanifest.xml ' s <application> tag, whic H would cause that class to being instantiated for if the process for your application/package is created.
Base class for those who need to maintain global application state. You can provide your own implementation by specifying it name in your androidmanifest.xml ' s <application> tag, whic H would cause that class to being instantiated for if the process for your application/package is created.

Do you first execute the class for the name of the application or the class for name in the activity?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.