Android App Overview
What is an app?
App is an abbreviation of application. Apps are software programs that are executed in a computer, smartphone or other device. The most common use for the term app is to denominate software programs that run on smartphones or mobile devices. In Android, apps contain compiled Java code, data files and resources files used by each app. All of this comes packed up in a file denominated Android Application Package (APK), with extension .apk. APKs are a variant of Java's JAR format. Apps are packaged by using the tool AAPT (Android Asset Packaging Tool) which is included in Android SDK. To package an application, Java code is compiled, then, compiled libraries are also included and all the code is optimized so it can be executed in android runtime.
Types of Android Applications
- Foreground Apps - These apps have a graphical interface that is executed while the user is using it. As soon as the app closes, these stop their execution. When a user exits the application and this is not closed, the app is suspended and uses less resources. Suspended apps can be cleaned up by Android’s resource management and this happens as a last resource when the device is running low on memory. Games are the most common examples.
- Background Apps - These are applications that are executed in the background in a silent manner. They have little or no interaction with the user. This type of applications usually waits for an event to be generated by any hardware peripheral or any message received in order to make an action. These applications are less common, but good examples include call screening applications, SMS auto-responders, and alarm clocks.
- Intermittent Apps - Intermittent applications are a combination of the two previous types. These apps have a graphical interface where the user can interact with the app, but also listens in the background for events. An example of this type of applications are chat applications, where the user can receive messages even though the app is closed and can also open the app and read all of the messages received.
- Widgets - These are applications that have a small graphic interface within the user’s home screen and are also known as mini-apps. The user can interact with the widget without the need of opening the app. A user can move widgets through the launcher’s home pages or change their size if the widget supports it. Widgets are commonly used to display information to the user, for example, weather widget, news widget etc.
Components of Android App
Android Apps are built with a combination of activities, services, intents, content providers and broadcast receivers. However, it is not required that apps use all of those components; it depends on each application.
- Activities - An activity is a single, standalone module of application functionality that usually correlates directly to a single user interface screen and its corresponding functionality. Activities are intended as fully reusable and interchangeable building blocks that can be shared amongst different applications. An existing email application, for example, might contain an activity specifically for composing and sending an email message. A developer might be writing an application that also has a requirement to send an email message. Rather than develop an email composition activity specifically for the new application, the developer can simply use the activity from the existing email application.
- Intents - Intents are the mechanism by which one activity is able to launch another and implement the flow through the activities that make up an app. Intents consist of a description of the operation to be performed and, optionally, the data on which it is to be performed. Intents can be explicit, in that they request the launch of a specific activity by referencing the activity by class name, or implicit by stating either the type of action to be performed or providing data of a specific type on which the action is to be performed. In the case of implicit intents, the Android runtime will select the activity to launch that most closely matches the criteria specified by the Intent using a process referred to as 'intent resolution'.
- Broadcast Receivers - Broadcast receivers are used to perform specific tasks when a system wide broadcast is detected. Some of these broadcasts are originated by the system. For example: incoming calls and sms, low battery, network state changed, image captured, etc. Apps can also register their own broadcast messages so other apps can listen and respond to them. When a matching intent is broadcast, the receiver will be invoked by the Android runtime regardless of whether the application that registered the receiver is currently running. The receiver then has 5 seconds in which to complete any tasks required of it before returning. Broadcast receivers operate in the background and do not have a user interface.
- Services - Services are used to perform prolonged tasks or tasks for remote processes in the background. Services do not have a graphical interface. Services are very important because they can execute processes while the user is performing other tasks. They can be started and subsequently managed from activities, broadcast receivers or other services. Although services lack a user interface, they can still notify the user of events using notifications and toasts and are also able to issue intents. Services are given a higher priority by the Android runtime than many other processes and will only be terminated as a last resort by the system in order to free up resources. In the event that the runtime does need to kill a service, however, it will be automatically restarted as soon as adequate resources once again become available.
- Content Providers - Content Providers manage access to a structured set of data. This data can be stored on the file system, in SQLite database or another persistent storage location. The main characteristic of the content provider is that they can share this data between applications. Data can be queried or modified through a content provider. In addition, content providers provide an encapsulated access to data. For example, the contact list is held in a content provider and for this reason, external applications such as Whatsapp or the sms app can access contacts. Access to the data is provided via a universal resource identifier (URI) defined by the content provider.
Stay tuned for next article.
hi
ReplyDelete