While learning a new language/ platform, it’s imperative to get oneself acquainted with the terminology. It’s analogous to making a new friend and improving your friendship. When we make friends with a new person, we try to find out quite a few attributes of that person apart from his name. If we want the friendship to thrive, we improve on it by knowing more about the friend, eg. his house, his family, the mobile he uses, his hobbies, etc. The same applies to learning Android. So let’s get acquainted with our new friend “Android”!!!
A Layout is a container for elements in the User Interface. We can declare our layout in two ways:
Additionally, a component can bind to a service to interact with it and even perform inter process communication (IPC). eg., a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.
2. Bound
We will discuss each of these in the later posts.
An example of Service can be a system that notifies the user when a sms has been received in the mobile.
9. Data Storage
Use this to store private primitive data in key-value pairs.
b. Internal Storage
Use this to store private data on the device memory. Data size is one attribute that is to be
kept in mind here.
c. External Storage
Use this option to store public data on the shared external storage. i.e. the sd card.
d. SQLite Databases
Use this to store structured data in a private database.
e. Network
You can also use the Internet to store and receive data, whether it's an SQLite database, or just a
simple text file.
Here are a few attributes which will help us to get better acquainted with our friend.
1. Activity
An Activity is a single screen of the User interface. This Activity can hold a hierarchy of views to give the UI the functionality it needs.
eg. For an email-application, we can have 3 Activities:
1. To log in.
2. To list all the mails we have received (and to interact with them).
3. To write and send an email.
All the above Activities are related, but they work separately on their own.
2. View
This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. The Views are placed inside the Layouts and with them we can create the most simple of UI to the most complex one. Android gives us the choice to work with XML to create UI. This is a good way to separate functionality from User Interface.
3. LayoutA Layout is a container for elements in the User Interface. We can declare our layout in two ways:
· Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.
· Instantiate layout elements at runtime. Our application can create View and ViewGroup objects (and manipulate their properties) programmatically. Every time we define a ‘.xml’ file with a specific user interface, we need to use these elements to hold hierarchy view tree. We have different layouts like RelativeLayout and LinearLayout, depending on its properties and relationship with the elements its holds. Layouts can be nested one inside another.
4. ServiceA Service runs in the background and doesn’t have UI.
A service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component, say activity, can start a service and it will continue to run in the background even if the user switches to another application.Additionally, a component can bind to a service to interact with it and even perform inter process communication (IPC). eg., a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.
A service can essentially take two forms:
1. Started2. Bound
We will discuss each of these in the later posts.
An example of Service can be a system that notifies the user when a sms has been received in the mobile.
5. Content provider
With content providers, we can access to any data stored in the device form an application. This data can be stored in files or is the SQLite database. They're the only way to share data across applications; there's no common storage area that all Android packages can access. Android ships with a number of built-in content providers eg. Contact information. They are listed in the android.provider package.6. Intents
Objects of type "android.content.Intent" are used to send asynchronous messages within your application or between applications. Intents allow to send or receive data from and to other activities or services. They also allow to broadcast that a certain event has occurred. Intents are also used to start one activity from another.Intents are powerful because they allow for loose coupling of applications.
Android supports implicit as well as explicit intents, the details of which we shall discuss later.7. Events
An Event is something that occurs form the “outside”. It is something we don’t control, the time of which we cannot predict. When an event occurs, our application might want to do some processing based on the event that has occurred. For that we use the Event controllers. For each event that can happen, we can define how the system is going to react to it.
A common event is onTouch Event which occurs when the screen is touched. We define event listeners to capture this event and do the processing.
8. Application Resources
Resources are the external elements we use in our applications. They are placed in the “res” folder in the project and they can be images, icons, music files, videos.
This folder also contains the various string resources used in the application, various layout files and themes, all stored as .xml files. Once resources are compiled, they are available in Java code using the "R.java" file. 9. Data Storage
Android provides several options to save persistent application data. The solution we choose depends on our specific needs, such as the privacy level and the size of the data.
Data storage options:
a. Shared PreferencesUse this to store private primitive data in key-value pairs.
b. Internal Storage
Use this to store private data on the device memory. Data size is one attribute that is to be
kept in mind here.
c. External Storage
Use this option to store public data on the shared external storage. i.e. the sd card.
d. SQLite Databases
Use this to store structured data in a private database.
e. Network
You can also use the Internet to store and receive data, whether it's an SQLite database, or just a
simple text file.
10. Security
Android is a privilege-separated operating system, in which each application runs with a distinct system identity (Linux user ID and group ID). Parts of the system are also separated into distinct identities. Linux thereby isolates applications from each other and from the system. Android basically deals with Inter Component Communication. Security encompasses a variety of topics like Application signing, file access, creating and using ‘Permissions’, etc. which we will cover up in detail later on.11. Using Web Services
One of the most powerful aspects of any mobile application for a smart phone is that it can connect to the Internet. By connecting to the Internet the application can offer much more value to the user since it becomes an interface for a web-based component, e.g. using Twitter APIs to create a Twitter application so that you can get your Twitter updates without having to open the mobile browser. Android offers many options to use web services. We shall discuss these soon.There. That’s a good enough introduction to our new friend. The more you try to get to know about these components, the better you will befriend Android. J