Today we will discuss about basic building blocks of an app.
As a website has webpages, an app has activities. An Android app is essentially a collection of different activities and services.
An activity controls what a user sees on screen and how he/she interacts with it.
An activity basically consists of 2 things. An xml file containing the layout and all the components of the user interface and a java class file that links the front-end of the app to the back-end and makes the app respond to the actions performed by the user.
A service does all the time consuming tasks in the background. It does not provide a user interface. This component significantly increases the speeds of the app.
For example, in an app that plays music from your on device collection of audio, using a service to get a list of all the audio files on your device will be very useful. Also, a service can be use to play audio even when the app is not running in the foreground.
- Content Providers
A content provider manages a shared set of app data. You can store your app’s data at any place it can acces, like the interna memory of your device, an SQLite database or even on a remote server over the internet.
Through the content provider, other apps may or may not be able to access your app’s data depending upon the access you allow.
For example, if you have an app for taking down notes, you can use the content provider to save the notes to your device’s internal or external memory as well as to later on retrieve the notes.
- Broadcast Receivers
A broadcast receiver is used to respond to system-wide broadcast announcements or to initiate an announcement.
Broadcast receivers themselves do not do anything except transmitting instructions, but they can be used to create status bar notifications or to initiate some service based on some event.
We will further explore these components in my future posts. Till then keep checking for more tutorials and keep coding.