Android apps typically consist of some, or all, the four different components listed following:
An activity provides a screen with which users can interact in order to do something. Sometimes, it could include a few fragments inside. A fragment represents a behaviour or a portion of user interface in an activity. Users can perform operations such as making a call, sending an SMS, and so on. A good example of an activity could be the login screen of your Facebook app. The following screenshot shows the activity of the calculator application:
A service can perform long-running operations in the background and does not provide a user interface. If you take the music application, you can close all of its screens after selecting the song of your choice. Still the music will be playing in the background. The following screenshot shows the services running on my device:
A broadcast receiver is a component that responds to system-wide broadcast announcements such as battery low, boot completed, headset plug, and so on. Though most of the broadcast receivers are originated by the system, applications can also announce broadcasts. From a developer's viewpoint, when the app needs to do some action only when there is a a specific event broadcast receiver is used.
A content provider presents data to external applications as one or more tables. When applications want to share their data with other applications, a content provider is a way, which acts as an interface for sharing data among applications. Content providers use standard insert()
, query()
, update()
, delete()
methods to access application data. A special form of URI that starts with content://
is assigned to each content provider. Any app, which knows this URI, can insert, update, delete, and query data from the database of the provider app if it has proper permissions.
Example: Using content://sms/inbox
content providers, any app can read SMS from the inbuilt SMS app's repository in our device. *READ_SMS
permission must be declared in the app's AndroidManifest.xml
file in order to access the SMS app's data.
In all the previous sections, we have been dealing with APK files only. It is important to understand how these APK files are created behind the screens. When a developer builds an app using an IDE such as Android Studio, typically he performs the following at a high level.
As we have seen earlier, an Android project usually contains a Java source, which is compiled into classes.dex
, a binary version of AndroidManifest.xml
and other resources that are bundled together during the compilation and packaging process. Once it is done, the app has to be signed by the developer. Finally, it is ready to install and run on the device.
Though it looks very simple from a developer's point of view, it consists of complex processes behind the screens. Let's see how the whole build system works.
According to Google's official documentation, following is the complete build system process:
AndroidManifest.xml
and other XML files used for designing the UI for the activities. This process is done using a tool known as aapt (short for Android Asset Packaging Tool). This tool generates a file called R.java
with a couple of constants inside it enabling us to reference them from our Java code:.aidl
(Android Interface Definition Language) files are used in the project, the aidl tool converts them to .java
files. Usually AIDL files are used when we allow clients from different applications to access your service for IPC and want to handle multithreading in your service. .class
files..class
files have to be converted into .dex
files. This is done by the dx tool. This process generates a single DEX file with the name classes.dex
.classes.dex
file generated in the previous step, resources that are not compiled such as images, and compiled resources are sent to the Apk Builder tool, which packages all these things into an APK file.Reference: http://developer.android.com/sdk/installing/studio-build.html.
18.225.234.28