Translate

Sunday, 31 January 2016

Android Emulator

Android Emulator is used to run, debug and test the android application. If you don't have the real device, it can be the best way to run, debug and test the application.
It uses an open source processor emulator technology called QEMU.
The emulator tool enables you to start the emulator from the command line. You need to write:
emulator -avd <AVD NAME>
In case of Eclipse IDE, you can create AVD by Window menu > AVD Manager > New. In the given image, you can see the android emulator, it displays the output of the hello android example.
hello android example

Saturday, 30 January 2016

Android Core Building Blocks

android components
An android component is simply a piece of code that has a well defined life cycle e.g. Activity, Receiver, Service etc.
The core building blocks or fundamental components of android are activities, views, intents, services, content providers, fragments and AndroidManifest.xml.

Activity

An activity is a class that represents a single screen. It is like a Frame in AWT.

View

A view is the UI element such as button, label, text field etc. Anything that you see is a view.

Intent

Intent is used to invoke components. It is mainly used to:
  • Start the service
  • Launch an activity
  • Display a web page
  • Display a list of contacts
  • Broadcast a message
  • Dial a phone call etc.
For example, you may write the following code to view the webpage.

Service

Service is a background process that can run for a long time.
There are two types of services local and remote. Local service is accessed from within the application whereas remote service is accessed remotely from other applications running on the same device.

Content Provider

Content Providers are used to share data between the applications.

Fragment

Fragments are like parts of activity. An activity can display one or more fragments on the screen at the same time.

AndroidManifest.xml

It contains informations about activities, content providers, permissions etc. It is like the web.xml file in Java EE.

Android Virtual Device (AVD)

It is used to test the android application without the need for mobile or tablet etc. It can be created in different configurations to emulate different types of real devices.

Thursday, 28 January 2016

Content Providers

A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. The data may be stored in the file system, the database or somewhere else entirely.
A content provider is implemented as a subclass of ContentProvider class and must implement a standard set of APIs that enable other applications to perform transactions.
public class MyContentProvider extends  ContentProvider {
   
   public void onCreate(){}

}


Additional Components

There are additional components which will be used in the construction of 
above mentioned entities, their logic, and wiring between them. 
These components are −

ComponentsDescription
Fragments
Represents a portion of user interface in an Activity.
Views
UI elements that are drawn on-screen including buttons, lists forms etc.
Layouts
View hierarchies that control screen format and appearance of the views.
Intents
Messages wiring components together.
Resources
External elements, such as strings, constants and drawable pictures.
Manifest
Configuration file for the application.




Tuesday, 26 January 2016

Services

A service is a component that runs in the background to perform long-running operations. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity.
A service is implemented as a subclass of Service class as follows −
public class MyService extends Service {

}

Broadcast Receivers

Broadcast Receivers simply respond to broadcast messages from other applications or from the system. For example, applications can also initiate broadcasts to let other applications know that some data has been downloaded to the device and is available for them to use, so this is broadcast receiver who will intercept this communication and will initiate appropriate action.
A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each message is broadcaster as an Intent object.
public class MyReceiver  extends  BroadcastReceiver {
   
   public void onReceive(context,intent){}

}

Monday, 25 January 2016

Android - Application Components

Application components are the essential building blocks of an Android application. These components are loosely coupled by the application manifest file AndroidManifest.xml that describes each component of the application and how they interact.
There are following four main components that can be used within an Android application:

ComponentsDescription
        ActivitiesThey dictate the UI and handle the user interaction to the smart phone screen
        ServicesThey handle background processing associated with an application.
        Broadcast  ReceiversThey handle communication between Android OS and applications.
        Content ProvidersThey handle data and database management issues.

Activities

An activity represents a single screen with a user interface,in-short Activity performs actions on the screen. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. If an application has more than one activity, then one of them should be marked as the activity that is presented when the application is launched.
An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity {

}

Saturday, 23 January 2016

Android Architecture


Friday, 22 January 2016

History of Android

The history and versions of android are interesting to know. The code names of android ranges from A to J currently, such as Aestro, Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream Sandwitch, Jelly Bean, KitKat and Lollipop. Let's understand the android history in a sequence.
1) Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States in October, 2003.
2) In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary of Google Incorporation.
3) The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris White and Nick Sears.
4) Originally intended for camera but shifted to smart phones later because of low market for camera only.
5) Android is the nick name of Andy Rubin given by coworkers because of his love to robots.
6) In 2007, Google announces the development of android OS.
7) In 2008, HTC launched the first android mobile.

Android Versions, Codename and API

Let's see the android versions, codenames and API Level provided by Google.
VersionCode nameAPI Level
     1.5       Cupcake      3
     1.6       Donut       4
     2.1       Éclair      7
     2.2        Froyo      8
     2.3       Gingerbread      9 and 10
     3.1 and 3.3       Honeycomb      12 and 13
     4.0       Ice Cream Sandwitch      15
    4.1, 4.2 and 4.3       Jelly Bean      16, 17 and 18
    4.4       KitKat      19
    5.0       Lollipop      21

Wednesday, 20 January 2016

Android Introduction

Android is an open source and Linux-based Operating System for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.
Android offers a unified approach to application development for mobile devices which means developers need only develop for Android, and their applications should be able to run on different devices powered by Android. Android is a complete set of software for mobile devices such as tablet computers, notebooks, smartphones, electronic book readers, set-top boxes etc.


Android applications are usually developed in the Java language using the Android Software Development Kit.
Once developed, Android applications can be packaged easily and sold out either through a store such as Google Play,SlideME,Opera Mobile Store,Mobango,F-droid and the Amazon Appstore.
Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It's the largest installed base of any mobile platform and growing fast. Every day more than 1 million new Android devices are activated worldwide.
This tutorial has been written with an aim to teach you how to develop and package Android application. We will start from environment setup for Android application programming and then drill down to look into various aspects of Android applications.