Wednesday, September 21, 2011

Android AVD Creation

Set up the AVD

Go to windows -> Android SDK and AVD Manager


 
 Click new


Give a name to the AVD and fill the other information as follows and click Create AVD



  After Create AVD you will see like this


Now you need to press Start and Lunch.
And Last but not the least RUN the Project ---> Run as Android Application.



This is how our first program look like




For Project creation See this link http://adroit-android.blogspot.com/2011/09/android-project-setup.html

Tuesday, September 20, 2011

Android Project Setup

Creating Android Project

Here we going to create Android project which will display Hello world message.
Enter Clt + N the new resource dialog will open, type Android and select Android Project



New project window will open enter the Project name select the Build target 2.2 or higher . Enter application name and package name.



Eclipse will create project with following structure



Android Project Structure

Src : This folder have all the java files
Gen : This folder contain R.java which is a android generated file . R.java contain id for all of the resources under the ‘Res’ folder which can be used in the java file to access those resources.
Res : Contains project resource files
Drawable : all the images and theme files store in this directory
Layout : This folder contain the xml files which having the screen layout.
String.xml : all the hard coded values are stored in this file. This is use full for multi-language

AndroidManifest.xml : This file have application lever configuration information. This file include declaration of all activities ,Services , User Permission , Screen orientation etc.



The main.xml will have the layout for the display panel which shows the Hello world message. The panel specify the main layout and a Text field in it which display the message.


In the above panel the TextField reading the message from the string.xml file the content of which will be look like bellow.


The Android generated R.java will look like this at this stage.




Android Activity life cycle.





 In the above diagram we can see that the onCreate method is the first method to execute. The layout for the activity has to specify in the onCreate method using the method setContentView(). Here you can see that how the android generated R class element used to refer to the resource file.





After completion of project creation we need to run the application , for that we need android AVD(Android Virtual Machine).The Procedure for Creating AVD........follow this Android AVD

http://adroit-android.blogspot.com/2011/09/android-avd-creation.html

Monday, September 19, 2011

Using link text or button in Android to redirect to url given

Using link text or button in Android

Here use the below code for link ,when clicked on the link or any linkItem it will redirect to the  page with given url .
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(http://www.adroit-android.blogspot.com/));
            startActivity(browserIntent);

Wednesday, September 14, 2011

Android Environment Setup


This tutorial will help to set up the environment for Android ,give an idea of Android project structure and an example program to start with Android.

Set up Eclipse

1. Download Eclipse from http://www.eclipse.org/downloads/ and setup the Eclipse

2. Install Android SDK from http://developer.android.com/sdk/index.html select the .exe

3. Install the Android plugin for Eclipse

Go to Help -> Install New Software


Enter the plugin URL as https://dl-ssl.google.com/android/eclipse/
and click Add
 
Enter the plugin name and click OK. This will load all the components of the plugin
 
Click Select All and click Next
 
Click Next

 

Accept the license agreement and click Finish

 
Once the plugin installation finish it will ask to restart the Eclipse

Now loading an Android SDK in eclipse.

SetUp Android Environment 


Go to Windows -> Preferences.


 
Select Android from the left panel and in the right panel brows to the Android SDK location and click OK



Next Apply and Ok .





Understanding Android Architecture Fundamental Components


Understanding Android Applications
Android applications are written in the Java programming language. The Android SDK tools compile the code—along with any data and resource files—into an Android package, an archive file with an .apk suffix. All the code in a single .apk file is considered to be one application and is the file that Android-powered devices use to install the application.

Application Components
Application components are the essential building blocks of an Android application. Each component is a different point through which the system can enter your application. Not all components are actual entry points for the user and some depend on each other, but each one exists as its own entity and plays a specific role—each one is a unique building block that helps define your application's overall behavior.

The fundamental building blocks / components of Android are:
1. Activities
2. Services
3. Broadcast Receivers
4. Content Providers.

Activities
An activity represents a single screen with a user interface(one single 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.
An activity is implemented as a subclass of Activity.

Services
A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example,  it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it.

A service is implemented as a subclass of Service.
 
 Broadcast receivers
A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs.


Content providers
A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your application can access. Through the content provider, other applications can query or even modify the data (if the content provider allows it). For example, the Android system provides a content provider that manages the user's contact information. As such, any application with the proper permissions can query part of the content provider (such as ContactsContract.Data) to read and write information about a particular person.
A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other applications to perform transactions. For more information, see the Content Providers developer guide.