Application name in androidmanifest. xml

Source: Internet
Author: User

The Android: Name attribute is used to set which application belongs to all activities. The default value is Android. App. application.

You can also define a class by yourself, for example:
Public class testapplication extends application {}

The function of this class is to put some global variables and methods used in the context.
Then add the Android: Name attribute to the <application/> node in androidmanifest. xml.

<Application Android: icon = "@ drawable/icon"

Android: Label = "@ string/app_name" Android: Name = ". testapplication">

In this way, we can set the default application to our custom testapplication.

The benefit of this solution is that, if an application exits, its lifecycle also ends,

If a static class is used, the program will not be recycled by GC immediately after exiting. When you enter the static class again, you will find the information saved by the static class.

Yes. The program may not be initialized as you want.

 

PS: testapplication must specify that the class field is public. Otherwise, an error will be reported during running and this class cannot be found.

Even if it is written as follows: Class testapplication extends application {}

No, because it is only visible to the package by default.

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.