android entry activity

  An android application consists of one or more activities. Each activity is not closely related, because we can call other activities in our own program, especially the activities generated outside our own code, such as the one provided by android. Activity for texting or calling.

        Intent call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phonenumber); 
        startActivity(call); 
        
        Intent sms = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:"+phonenumber); 
        startActivity (sms); 
    From this point of view, the android application is actually assembled by multiple activities in a certain order, but in the process of assembly, some data is passed in the background, so that each activity can be better Linked up. 
    After so much, in fact, I still want to say that in android applications, there is no main function like c++ and java as the entry of the application. The android application provides the entry Activity, not the entry. Function. 
    When creating an android application in eclipse, an Activity will be created by default. This Activity is actually the entry Activity. Where do you define it as an Activity? The AndroidManifest.xml file defines the Activity contained in the entire android application. .The definition of the default generated Activity is: 
        <activity android:name=".activity01" android:label="@string/app_name"> 
            <intent-filter> 
                <action android:name="android.intent.action.MAIN" /> 
                <category android:name="android.intent.category.LAUNCHER" /> 
            </intent-filter> 
        </activity> 
    android in action node. Intent.action.MAIN indicates that the Activity it is in is the entry point of the entire application . And android.intent.category.LAUNCHER in category means to attribute this Activityg to the loader class , that is, marking this Activity as automatically loading and Started Activity, so that the Activity will be loaded first when the program starts. The reference manual says so----"the LAUNCHER category says that this entry point should be listed in the application launcher." The meaning and my understanding are In and out. But the meaning is that this Activity is to be loaded by the application. 
    We can compare the log output from the console side in eclipse. Initially, I commented out the line <category android:name="android.intent.category.LAUNCHER" /> in the original xml file. You can see When I go to the console, it will report an error of "No Launcher activity found!". In fact, the app "lifecycle_test" cannot be found in the application list on the virtual device at this time, and it cannot be run, and it cannot be loaded at all. The comment will be removed later. , restore to the initial state, and then start the application, you can see that the "No Launcher activity found!" part of the error message is gone, and on the screen of the virtual device, you can see that the "lifecycle_test" app has been successfully run.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326790234&siteId=291194637