What is Android?
Android is an operating system developed by Google that is dedicated to mobile devices.Android is based on Linux.Android core libraries are written in C ,C++ and Java.Android platform is written in Java.Android uses a virtual machine – Dalvik.Android offers a set of APIs in the Java language for application developers.
Activity : Activity is the presenter of a single screen in the application. It is the only one who has certain abilities, like displaying Views, menus, alerts and notifications. It also has the ability to open a new Activity, which means opening a new screen.Activity is a class which derives from android.app.Activity.An application needs to have at least one Activity.All Activities must be declared in the manifest file.
View : A view is a single user interface element. Its responsibilities include drawing on a canvas and handling user events. Some Views can contain other Views, these are called view groups. A View is a class which derives from android. There are already many existing views. The developer can use them or create his own customized view by extending any of them.
Intent : Intent is the negotiator between two activities or between two applications. It gives the ability to pass messages and data between the two entities. When writing applications for mobile, Intent is very handy, since it gives access to a lot of the OS services like opening the camera, a browser, displaying notifications and so on
Service : A Service is an application which has the ability to run in the background without displaying any user interface. A Service is a class which derives from android.app.Service. All Services must be declared in the manifest file
Environemnt Installation
Option 1 – Eclipse Plugin
If you have an Eclipse installed and you wish to continue working with it, you can do so by installing the Android Eclipse Plugin.
http://developer.android.com/sdk/eclipse-adt.html
If you have an Eclipse installed and you wish to continue working with it, you can do so by installing the Android Eclipse Plugin.
http://developer.android.com/sdk/eclipse-adt.html
Option 2 – Android Development Tools (ADT) Bundle
The ADT Bundle is a complete package of Eclipse with Android plugin and Android SDK with all the extra tools. So this is probably a good options if you are starting from scratch.
http://developer.android.com/sdk/installing/bundle.html
The ADT Bundle is a complete package of Eclipse with Android plugin and Android SDK with all the extra tools. So this is probably a good options if you are starting from scratch.
http://developer.android.com/sdk/installing/bundle.html
Option 3 – Android studio
If you like inteliJ morte than a Eclipse, than this is probably the best option for you. This one also includes every thing the ADT bundle includes.
http://developer.android.com/sdk/installing/studio.html
If you like inteliJ morte than a Eclipse, than this is probably the best option for you. This one also includes every thing the ADT bundle includes.
http://developer.android.com/sdk/installing/studio.html
Creating a project
In Eclipse: Select File > New > Android Project.
In Android Studio: Select File > New Project.
In Eclipse: Select File > New > Android Project.
In Android Studio: Select File > New Project.
Enter the project properties:
Application name – this is how the user sees the title of your application
Project Name – The java eclipse project name.
Build SDK – The Android SDK version you will use to develope your application.
Minimum required SDK – The minimum Android API version to be supported by your application.
Package name – Android demands each application to declare its root package
Application name – this is how the user sees the title of your application
Project Name – The java eclipse project name.
Build SDK – The Android SDK version you will use to develope your application.
Minimum required SDK – The minimum Android API version to be supported by your application.
Package name – Android demands each application to declare its root package
Click on ‘Next’ twice
Create Activity + Activity name Click on ‘Finish’.
An Android project structure
Manifest file : Android Mani fest.xml defines the Android application project. It defines the attributes, activities, versions, permissions, and other parameters of the application.
Manifest file : Android Mani fest.xml defines the Android application project. It defines the attributes, activities, versions, permissions, and other parameters of the application.
‘src’ folder :As any Java project, this folder holds all the Java sources and packages.
‘res’ folder :Holds any local resources of the application:
‘drawable’ – image folders according to resolutions. By default there are 3 folders for 3 basic resolutions.’layout’ – xml files which represent display layout. By default a main.xml is created.’values’ – xml files which define global constants, strings, styles or colors.
*Note: files in the res folder may be modified for optimization purposes.
*Note: files in the res folder may be modified for optimization purposes.
SDK jar: Holds the android.jar which is different from versions of the SDK.
‘gen’ folder: Contains the R class which is a class that is automatically generated by the Eclipse plugin and gives access to the projects resources.
‘assets’ folder: Holds other raw resource files such as movies or sound files. By default this folder is not created. These resources will not be modified.
Creating Android Virtual Device (AVD): The developer can test his applications on an emulator which comes along with Android SDK. But first the developer has to define a virtual device which suits his needs.
To create an AVD:
In Eclipse: select Window > AVD Manager
In Android Studio: select Tools > AVD Manager
or click the AVD Manager icon from the toolbar.In the Virtual Devices panel, you’ll see a list of existing AVDs. Click New to create a new AVD.Fill in the details for the AVD and click “Create AVD”.
In Eclipse: select Window > AVD Manager
In Android Studio: select Tools > AVD Manager
or click the AVD Manager icon from the toolbar.In the Virtual Devices panel, you’ll see a list of existing AVDs. Click New to create a new AVD.Fill in the details for the AVD and click “Create AVD”.
Signing and generating jars
Android applications as other applications are zipped to jar files. The only difference is that Android jar files have a different extension – .apk. All application jars have to be signed before they are installed. Please follow instructions in: http://developer.android.com/guide/publishing/app-signing.html
Views
Creating and adding a new View to a Layout
XML example – Adding to a view in a layout xml file
Android applications as other applications are zipped to jar files. The only difference is that Android jar files have a different extension – .apk. All application jars have to be signed before they are installed. Please follow instructions in: http://developer.android.com/guide/publishing/app-signing.html
Views
Creating and adding a new View to a Layout
XML example – Adding to a view in a layout xml file
Code example – Creating and adding a new view to a Layout (implemented in an Activity class).
View Groups
A ViewGroup is a special view that can contain other views.