Application components are the basic building blocks of an Android application. These components are loosely coupled. The application manifest file AndroidManifest.xml describes each component of the application and how they interact with each other. There are four main components that can be used in an Android application:
ActivitiesAn activity represents a single user interface on the screen. For example, an email application might have one activity that displays a list of new emails, another activity for composing emails, and another activity for reading emails. If the application has more than one activity, then one of them should be marked as the activity presented when the application is launched. It is implemented as a subclass of the Activity class as follows:
ServicesA service is a component that runs in the background to perform long-running operations. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking the user from interacting with the activity. Implementing a service as a subclass of a service class is as follows:
Broadcast ReceiverBroadcast receivers simply respond to broadcast messages from other applications or from the system. For example, an application can also initiate a broadcast to let other applications know that some data has been downloaded to the device and is available for them to use, so it is the broadcast receiver that will intercept this communication and take appropriate action. Broadcast receivers are implemented as subclasses of the BroadcastReceiver class, and each message is broadcast as an Intent object.
Content ProviderContent provider components provide data from one application to other upon request. Such requests are handled by methods of the ContentResolver class. The data can be stored in the file system, a database or elsewhere. Content providers implement subclasses of the ContentProvider class and must implement a standard set of APIs that enable other applications to perform transactions.
We will cover the details of the application components through these tags, also in separate chapters. Add-onsAdditional components can be used to construct the above entities, their logic and the connections between them. These components include:
|
<<: Apple Swift language open source project selection summary
>>: Apple to launch dedicated app for Apple Watch
It seems that many entrepreneurs like to talk abo...
Toutiao is one of the important platforms of self...
The decline of the traditional PC industry has no...
Miaopai is really brave On September 22, the cost...
The cute "Jerboa" that appeared in the ...
On February 18, Guangdong Province held a provinc...
Speaking of urinary tract infections Many female ...
In the Internet age, traffic is money. With traff...
Previously, whenever we talked about business and...
As the Internet has developed to a certain stage,...
Pop art master Andy Warhol said that everyone can...
In May, Apple once again cleaned up a large numbe...
How much does it cost to join a fitness app in Zh...
Currently, the number of apps in the App Store ha...