Android App application global variable access

Source: Internet
Author: User

Recently in the writing of an Android project, I wrote a androidapplication global variable, which wrote some methods to get the application package name and system, but I every time when the call is an empty exception, I think I should write all write, what singleton mode, has not found the reason, Take the time to study today, it turns out I made a mistake before, originally application and Activity,service is a system component of the Android framework, When the Android program starts, the system creates a Application object to store some information about the system. Usually we do not need to specify a application, then the system will automatically help us create. By opening the manifest file for each application, you can see that the activity is included in the application tag:

, here I did not give my application of the application to specify an object, so I entered the Application object I wrote is also empty, so as long as it is added here, I hope that the same people who have encountered such problems have helped, there are problems we can exchange.

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

Android App application global variable access

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.