Saturday 28 September 2013

How to Develop Your First Android App


Android beginner friends to develop your " First Android App” you need to follow below steps

Step 1: Open Eclipse IDE.




Step 2: Go to Menu Bar select File -> New -> (Click on)Project  a new popup window will come


Step 3: Select Android Application Project and click on "Next" button then New Android App popup will come as below screen. Now fill up "Application Name" "Project Name" and "Package Name" for that use Java naming convention means first letter of each word start with capital letter  like "MyFirstApp" .



  
Step 4: Follow below screen then click on Next button then will come new popup window again click on Next button.



Step 4: Now follow below screen and fill up "Activity Name" "Layout name(layout name shoul be in small letter and keep under score symbol between two words like "my_first_app")" and "Title(can write 2 to 3 words)" now click on "Finish"  button.


Step 5: Now you can modify "xml" editor like below using drag and drop  widgets features of this framework. 


Step 6: After modifying "xml" editor launch your AVD(Android Virtual Device)

Step 7: To run your First Android App right click on your project and click on "Run As-->1 Android Application " or select your project and press " F11" to run your App. 

For live watch below video to develop your "First Android App". Need latest Adobe Flash Player to watch this video







main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#9966FF"
        android:textStyle="bold"
        android:textSize="30sp"
        android:text="This is my first app." />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="CheckBox" />

    <RadioButton
        android:id="@+id/radioButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="RadioButton" />

</LinearLayout>


MyFirstAppActivity.java


package com.example.myfirstapp;

import android.os.Bundle;
import android.app.Activity;


public class MyFirstAppActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

          }
}


AndroidManifest.xml



<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MyFirstAppActivity"
            android:label="@string/title_activity_my_first_app" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>



strings.xml

resources>

    <string name="app_name">MyFirstApp</string>
    <string name="hello_world">Hello world!</string>
    <string name="menu_settings">Settings</string>
    <string name="title_activity_my_first_app">My First App</string>

</resources>













Wednesday 28 August 2013

Tutorial to Start Android Apps Development for Beginners

If you want to develop your first Android Application using Eclipse IDE (Without using Android Studio) with Windows then follow below steps.

Step 1.

First of all you need to install and set path of JDK 1.x.

How to set Path Environment Variable in Windows:

Windows XP:
Select Start, select Control Panel double click System, and select the Advanced tab.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows Vista:
From the desktop, right click the My Computer icon.
Choose Properties from the context menu.
Click the Advanced tab (Advanced system settings link in Vista).
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows 7:
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Also can follow below link to get more knowledge about setting CLASS PATH ENVIRONMENT


Step 2.

Unzip folder of Eclipse IDE then launch Eclipse will get popup window (no need to install it only double click on Eclipse icon) will get popup window and create Android Workspace Directory like below figure, clock on OK button, then workspace created within your specified drive. Now eclipse is running.

 
Step 3.

How to install ADT plug-in manually

After downloading ADT plug-in
Go to Menu Help --> Install New Software
like below figure


Click on “Add” button in the upper right corner of popup window.


Enter Name field with “ADT Plugin” like below figure.
Enter below URL address in the Location field.


Now click on “OK“button and wait until Developer Tools appear (if there is any issue use “http://” instead of “https ://”) check on checkbox of Developer Tools then click on Next button.


Now we will see the components that are installed, again click on “Next” button in below popup window.


Now to read and accept the license agreement click on “Radio” button and click Finish.


The download of components is starting. If comes the Security Warning that the authenticity or validity of the software can’t be established popup window click “OK”.


After finished have to restart Eclipse- click on Restart Now.

 
Step 4.

How to Install and Update SDK Tools Using SDK Manager

After restarting Eclipse if shows the following dialog with warning “ SDK Platform Tools component is missing! Please use the SDK Manager to install it. ” then press “Next” button in below popup window.


Now check “Yes” radio button and click on “Finish” button in below popup window.


Click on “OK” button.


Now go to “SDK Manager” and install it. Go to Window menu in Eclipse click on SDK Manager Label of drop down menu of Window.
In below window you can see that Status column about which API level and component is installed or not. In Name column you can know about API level and Android version which is installed.
In bottom of popup window by checking Radio button and Check button know all the information about installed or not installed components of SDK.
By checking Check box of Name column then click on Install package button and Delete package (Right bottom) of SDK manager popup window can installed or delete Packages of Android support libraries
By checking on Google APIs by Google Inc. Check box you can get facility to develop your Google Map enable apps.
Note: For platforms with versions 4.X choose SDK Platform and ARM EABI v7a System Image (for work with emulator).


After click on Install packages will come new popup window. In the new window by check on Accept All to download it all. Here you can also see the size of components and reject some by checking reject radio button. Now click on Install button it will take approx 20 minutes to install, after installation close the log and SDK manager then restart the Eclipse and your Eclipse environment will ready to develop your first Android App.


How to Install SDK Manually in Eclipse IDE in Android

Suppose after installation of ADT plug-in and Restart of Eclipse IDE following window is now open automatically or accidentally you closed then you have to install you have to install SDK manually.



Install SDK Manually:
Follow below figure.
In Eclipse go to Window-->Preferences (Select and click on)


Now select Android (If ADT plug-in is not installed Android will not show) so first install ADT plug-in before installation of SDK.
Go to SDK Location: label and click on Browse and browse your SDK directory or navigate SDK folder location path copy and paste in this label then select and check checkbox of targeted API level which you want then Apply button will highlight click and press “OK” button. Follow below figure for help.



If below Alert Dialog box is open click “OK” then go to SDK Manager and install that are missing like previous I have explained.


Note: Friends I want to told you if you want to protect from above all settings and issues use Android Studio which encapsulate with all these settings and tools

Step5.

How to Create AVD (Android Virtual Device)

The next step is to create an Android Virtual Device (AVD) to be used for testing your Android applications. An AVD is an emulator instance that enables you to model an actual device. Each AVD consists of a hardware profile, a mapping to a system image as well as emulated storage, such as a secure digital (SD) card.
You can create as many AVDs as you want in order to test your applications with several different configurations. This testing is important to confirm the behavior of your application when it is run on different devices with varying capabilities.
To create AVD you need to go menu Window -->AVD Manager (Select and Click) after open popup window click on “New” button to create AVD.




Enter the name of AVD in “Name” label select “Target” then check Size radio button and enter “SD Card Size” in label of Size. You can check “Snapshot” checkbox to enable snapshot facility through Emulator.
For getting Emulator “Skin” check radio button or give own screen resolution.


To get hardware functionality click on “New” button then will come a popup then press Enter Key of your key board until all the properties of hardware is not added, to facilitate all the hardware functionality of AVD like “Real Device” in Hardware label you will get slider facility to know which type of facility available in AVD.

Hardware options

If you are creating a new AVD, you can specify the following hardware options for the AVD to emulate:

Characteristic                         Description                                  Property

Device ram size         The amount of physical RAM on the device, in megabytes.
                                        Default value is "96".                                 hw.ramSize

Touch-screen support Whether there is a touch screen or not on the device.
                                        Default value is "yes".                                hw.touchScreen

Trackball support        Whether there is a trackball on the device. 
                                       Default value is "yes".                                  hw.trackBall

Keyboard support        Whether the device has a QWERTY keyboard. 
                                       Default value is "yes".                                    hw.keyboard

DPad support                Whether the device has DPad keys. 
                                      Default value is "yes"                                       .hw.dPad

GSM modem support     Whether there is a GSM modem in the device.
                                       Default value is "yes".                                      hw.gsmModem

Camera support       Whether the device has a camera. 
                                      Default value is "no".                                         hw.camera

Maximum horizontal       Default value is "640".           hw.camera.maxHorizontalPixels
 camera pixels

Maximum vertical      Default value is "480".                hw.camera.maxVerticalPixels
camera pixels

GPS support             Whether there is a GPS in the device.                      hw.gps
                                    Default value is "yes".                                                                      

Battery support    Whether the device can run on a battery.
                                   Default value is "yes".                                        hw.battery

Accelerometer Whether
 there is an accelerometer in the device.     Default value is "yes".                                                                                                                                                                   hw.accelerometer
Audio recording support
Whether the device can record audio.        Default value is "yes".     hw.audioInput

Audio playback support                            Default value is "yes".       hw.audioOutput
Whether the device can play audio.

SD Card support                                    Default value is "yes".               hw.sdCard
Whether the device supports insertion/removal of virtual SD Cards.                                                        

Cache partition support                            Default value is "yes".   disk.cachePartition
Whether we use a /cache partition on the device.                                                                                   

Cache partition  size                    Default value is "66MB".  disk.cachePartition.size    
     
Abstracted LCD density               Default value is "160".             hw.lcd.density
Sets the generalized density characteristic used by the AVD's screen.  

                                                                                                   


To enable key up and down and other functionally of keyboard of AVD scroll down below and click on “no” toggle button to get “Yes”. At last click on “Create AVD” button.   
If you want to get Google map enable AVD then you have to select “Google APIs (Google Inc.)” of specific API Level.

How to get AVD Details:

Select any AVD Name and click on "Details" button.



How to launch AVD:
To launch AVD select “existing AVD name” and click on “Start” then will get a popup of “Launch Options” you can also create manual screen size of AVD by check on checkbox of “Scale display to real size” then click on “Launch” button.


After launch you will get AVD like below figure.

 



Sunday 4 August 2013

Required Tools to Develop Android Applications with Procedure


  • Java 1.6 or higher is required.
  • Eclipse IDE (Integrated Development Environment)
  • ADT (Android Developer Tools) for Eclipse
  • Download the latest SDK or “devkit”(Software Development Kit)


Where we can get these tools?

Below are the links to get these




Download SDK           

Android Studio


If You want to get all above required development tools except JDK with a single download bundle then follow below link and download.
Android Studio:
                           A new Android Development Environment called “Android Studio” based on “InteliJ IDEA” is now available. It is similar to Eclipse with the ADT Plug-in. It provides integrated Android Developer Tools for development and debugging.
For details how to install it and start project for different platform like Windows, Mac OS X and Linux follow below link:




http://www.phonesreview.co.uk/wp-content/phoneimages/Android-Studio-hands-on-review.jpg

How to install Android Studio:

Download the Android Studio package and install android studio and SDK Tools for following platforms.

Windows:

  • Click on EXE file setup of android studio bundle.
  • If you get any problem to install setup then need to set and environment variable for indicating the correct location of Java where is installed.


  • Go to StartMenu->Computer->System Properties->Advanced System Properties->Open “Advance Tab”->Environment Variable and add new system variable JAVA_HOME which points to JDK folder like below path.


C:\Program Files\Java\jdk1.7.0_21.

Mac OS X:

  • Open the downloaded DMG file
  • Drag and drop android studio into the applications folder.
  • If you get any problem and getting warning message say that package is damaged then go to System Preference->Security & Privacy and under Allow applications downloaded from, select “anywhere” then launch Android Studio again.


Linux:

  • Unpack the downloaded “tgz” folder into an appropriate location of applications.
  • Launch android studio and navigate android-studio/bin/ directory in a terminal and execute studio.sh.
  • To start android studio form any directory add “android-studio/bin/” as PATH in environment variable.
If you get any issue to develop your android apps in Android Studio assist with following Link


Sunday 14 July 2013

Beginning of Android Applications Development

Welcome to the world of Android!


What is Android?


Android is a mobile operating system based on Linux, Android applications are written in Java programming.

It provides tools like compiler, debugger and an embedded device emulator (AVD-Android Virtual Device through which developer can check their apps) and own java virtual machine known as Dalvik Virtual Machine (DVM).

Android is officially guided by the Open Handset Alliance (OHA) but in reality it is Google Leading Project. It provides opens source code facility under the open source Apache License.
Android supports 2-D and 3-D graphics using the OpenGL libraries and support embedded data storage SQLite data base.

Every Android applications runs in its own process and under its own use “id” which is generated automatically by the Android System during development.

Therefore each application is isolated from other running applications and a misbehaving application cannot easily harm other Android Applications.

Features of Android

 Android is open source and freely available to manufacturers for customization, there are no fixed hardware or software configurations. However, Android itself supports the following features:

Storage — Uses SQLite a light weight relational database, for data storage.

Connectivity — Supports GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth (includes A2DP and AVRCP), Wi-Fi, LTE, and WiMAX. Messaging — Supports both SMS and MMS.

             Web browser — Based on the open source WebKit.

             Media support — Includes support for the following media: H.263, H.264 (in 3GP or MP4 container), MPEG-4 SP, AMR, AMR-WB (in 3GP container), AAC, HE-AAC (in MP4 or
3GP container), MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.

 Hardware support — Accelerometer Sensor, Camera, Digital Compass, Proximity Sensor, and GPS.

Multi-touch — Supports multi-touch screens.

Multi-tasking — Supports multi-tasking applications.

Flash support — Android 2.3 supports Flash 10.1.

Tethering — Supports sharing of Internet connections as a wired/wireless hotspot.


Architecture of Android

In order to understand how Android works, follow to the below figure, which shows the various
layers that make up the Android operating system (OS).

The Android OS is roughly divided into five sections in four main layers:

 Linux kernel — This is the kernel on which Android is based. This layer contains all the low level device drivers for the various hardware components of an Android device.

 Libraries — These contain all the code that provides the main features of an Android OS. For
example, the SQLite library provides database support so that an application can use it for
data storage. The WebKit library provides functionalities for web browsing.

Android runtime — At the same layer as the libraries, the Android runtime provides a set
of core libraries that enable developers to write Android apps using the Java programming
language. The Android runtime also includes the Dalvik Virtual Machine, which enables every
Android application to run in its own process, with its own instance of the Dalvik Virtual
Machine (Android applications are compiled into Dalvik executables). Dalvik is a specialized
virtual machine designed specifically for Android and optimized for battery-powered mobile
device with limited memory and CPU.

 Application framework — Expose the various capabilities of the Android OS to application
Developer  so that they can make use of them in their applications.

 Applications — At this top layer, you will find applications that ship with the Android device
(such as Phone, Contacts, Browser, etc.), as well as applications that you download and install from the Android Market. Any applications that you write are located at this layer.


https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxfRn5RLtPTmLtAtQ30Nf66visEQo1BFZJ6RqV6vro7sCblzw2oj2B4Gf0JHPkZrl5RaLaN_mCQ0-njyb5aNfYzyv4of7bXk5xG_XNFLLvPB1FlvaUDujO4s28o4dHlBpgGha1NlZWcOmQ/s1600/Android+Architecture+-+1.png