In this article on fundamentals of android application development we will discuss 4 basic building blocks of android application development from which android apps are built. These building blocks are implemented as java classes. First of these building blocks is the Activity Class.
This is the main class that users see when the run an application. Activities are designed to provide Graphical User Interface to user and this enable users to give and receive information to and from an application. Remaining 3 components work behind the scene and do not have user interfaces. These components includes
- Services – for supporting in the background ling running operations.
- Broadcast Receivers – Listens for and responds for the events that happen on a device
- Content Providers – Allows multiple applications to store and share data.
Apps are normally created from multiple collaborating components that android starts up and runs as necessary. Each of these components serves a different purpose in the android echo system, there fore has its own entry points and APIs. Let us explore all the components one by one.
This is primary class is for user interaction, as a general rule of thumb an activity should support a single focused thing that a user can perform like dialing a phone number, or entering a contact information of a person etc.
Services run in background so there is no GUI for them. Services has two main purposes, One is to run a long running processes
typically away from main UI thread. Second is they support interaction with remote processes.
Example of a service is music application in android phones. Suppose user plays a song in music player and then decides to read email, then in background music will be running.
Broadcast receivers listen to and responds to events. They play the role of subscriber in publish/subscribe pattern. In android events are represented by Intent class. Publishers creates these intents and then broadcast them using a method like context class’s send broadcast. Once broadcast these intents are then routed to the broadcast receivers that are subscribed to or registered for those specific intents and at which point they can respond. Messaging application is one example of broadcast receivers.
Content providers store and share data across applications. Content providers provide a database style user interface, but they are more then just databases. For example they will handle low level inter process communication. The Browser application is one application that uses content providers. when we open a browser it shows us a list of bookmarks or saved addresses, when a user adds a bookmark the browser application save it into a content provider.
Building and android application
– pic link: http://developer.android.com/tools/building/index.html
1. Start an android application
2. Compile you application and prepare the resources and includes non source code entities, layout strings, Images, menus, animations.
3. The out put of above process is and Android Package or APK file, That corresponds to our application executable.
4. APK file is digitally signed to identify us as developer.
5. Finally APK is installed on a device or Emulator and run.
There are 3 kind of strings in android, Strings, String Arrays and Plurals. Strings are typically stored in an XML file located at res/values/*.XML . It is specified in XML as follows.
<string name="hello">Hello World!</string>
It can also include styling and formatting information. These string are accessed by other resources as:
But in Java code we can access a string as
If we want to store word for another language the we can add an XML file inside res directory like values-it directory for Italian language strings having an XML file.
This article explain basic or fundamentals of android application development. In next article we will further explore android platform. If you want to know about android platform then you can visit this article on introduction to android platform.