Entry points for Android programs

Source: Internet
Author: User

Original: The entry point of the Android program

Android apps, consisting of one or more activity. Each activity is not closely related, because we can invoke other activity in our own program, especially the activity generated outside of our own code, For example, Android provides SMS or call activity.

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,Android apps are actually assembled by multiple activity in a certain order, but in the process of assembling, the backstage passed some data, so that the activity can be a better link up.
In Android applications, there is no main function like C + + and Java as the entry for the application.The Android app provides a portal activity,rather than the entry function.
When you create an Android application in Eclipse, an activity is created by default. This activity is actually an entry activity. The Androidmanifest.xml file defines the activity that is included in the entire Android app.The default generated activity is defined as:
<activity android:name= ". Activity01" android:label= "@string/app_name" >
<intent-filter>
<ActionAndroid:name= "Android.intent.action.MAIN"/>
<categoryAndroid:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
the Android.intent.action.MAIN in the action node indicates that the activity it is in is the entry point for the entire application.The Android.intent.category.LAUNCHER meaning in category is to attribute this activityg to the loader class, which is to label the activity as an activity that automatically loads and starts, So when the program starts, it loads the activity..

We can look at the logs from the console output in Eclipse. Initially, I put <category android:name= "Android.intent.category.LAUNCHER"/> This line has been commented out in the original XML file. You can see the console will error "No Launcher activity found!", in fact, in the virtual device in the list of applications cannot find the "Lifecycle_test" this app, and also can't run, It doesn't load at all. After you remove the comment, revert to the initial state, and then start the app and see "No Launcher activity found!" This part of the error message is not available, and the virtual device on the screen, you can see the "Lifecycle_test" the app has been successfully run.


[2011-08-11 09:29:10-lifecycle_test]------------------------------
[2011-08-11 09:29:10-lifecycle_test] Android launch!
[2011-08-11 09:29:10-lifecycle_test] adb is running normally.
[2011-08-11 09:29:10-lifecycle_test] No Launcher Activity found!
[2011-08-11 09:29:10-lifecycle_test] The launch would only sync the application package on the device!
[2011-08-11 09:29:10-lifecycle_test] Performing sync
[2011-08-11 09:29:10-lifecycle_test] Automatic Target mode:using existing emulator ' emulator-5554 ' running compatible AVD ' myavd_2.2 '
[2011-08-11 09:29:15-lifecycle_test] Application already deployed. No need to reinstall.
[2011-08-11 09:29:15-lifecycle_test] \lifecycle_test\bin\lifecycle_test.apk installed on device
[2011-08-11 09:29:15-lifecycle_test] done!
[2011-08-11 09:30:47-lifecycle_test]------------------------------
[2011-08-11 09:30:47-lifecycle_test] Android launch!
[2011-08-11 09:30:47-lifecycle_test] adb is running normally.
[2011-08-11 09:30:47-lifecycle_test] Performing TEST.ACTIVITY.LEIPEI.ACTIVITY01 activity launch
[2011-08-11 09:30:47-lifecycle_test] Automatic Target mode:using existing emulator ' emulator-5554 ' running compatible AVD ' myavd_2.2 '
[2011-08-11 09:30:47-lifecycle_test] Uploading lifecycle_test.apk onto device ' emulator-5554 '
[2011-08-11 09:30:47-lifecycle_test] Installing lifecycle_test.apk ...
[2011-08-11 09:30:54-lifecycle_test] success!
[2011-08-11 09:30:55-lifecycle_test] Starting activity test.activity.leipei.activity01 on device emulator-5554

[2011-08-11 09:30:57-lifecycle_test] ActivityManager:Starting:Intent {act=android.intent.action.main Cat=[android.intent.category.launcher] cmp= TEST.ACTIVITY.LEIPEI/.ACTIVITY01}





Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Entry points for Android programs

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.