What is the entry point of the Android program, not main ()?

Source: Internet
Author: User

Many of the first-entry Android Web pages may not know what the entry point of the Android program is, not main (), many users may be directly reply is OnCreate, of course, I believe that the reply oncreate is not really wrong, but you want to be in the activity OnCreate method, the Android development network here tells you what the real entry point entrypoint is.

Android uses a Google Dalvik VM, which differs greatly from traditional Java VMs in that the entry point in Sun's Java system is main () as in the standard C language, and each Android program contains a application instance. There are multiple activity, Service, ContentProvider, or broadcast Receiver in a application instance. Because most of the applications contain activity so, said many netizens think is the activity of OnCreate, but you did not find that your project has a number of activity? You may not have seen an Android app without activity.

In fact, in android.app.Application this package oncreate is the real Android entry point, but most developers do not have to rewrite the class, his inheritance relationship such as:

Java.lang.Object
? Android.content.Context
? Android.content.ContextWrapper
? Android.app.Application

The Android.app.Application class contains 4 public methods

void onconfigurationchanged (Configuration newconfig)
void OnCreate ()//This is the real entry point.
void Onlowmemory ()
void Onterminate ()

So I hope everyone, remember that the real Android entry point is application main, you can see the androidmanifest.xml of the inclusion of the relationship is clear, not every application must have activity.

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.