Monday, 16 November 2015

INTRODUCTION ON ANDROID & ITS ARCHITECTURE

22:56

What is Android?


Before learning all topics of android, it is required to know what is android.
Android is a software package and linux based operating system for mobile devices such as tablet computers and smartphones.
It is developed by Google and later the OHA (Open Handset Alliance). Java language is mainly used to write the android code even though other languages can be used.
The goal of android project is to create a successful real-world product that improves the mobile experience for end users.
There are many code names of android such as Lollipop, Kitkat, Jelly Bean, Ice cream Sandwich, Froyo, Ecliar, Donut etc which is covered in next page.


What is Open Handset Alliance (OHA)
It's a consortium of 84 companies such as google, samsung, AKM, synaptics, KDDI, Garmin, Teleca, Ebay, Intel etc.
It was established on 5th November, 2007, led by Google. It is committed to advance open standards, provide services and deploy handsets using the Android Plateform.


Features of Android
After learning what is android, let's see the features of android. The important features of android are given below:
1) It is open-source.
2) Anyone can customize the Android Platform.
3) There are a lot of mobile applications that can be chosen by the consumer.
4) It provides many interesting features like weather details, opening screen, live RSS (Really Simple Syndication) feeds etc.
It provides support for messaging services(SMS and MMS), web browser, storage (SQLite), connectivity (GSM, CDMA, Blue Tooth, Wi-Fi etc.), media, handset layout etc.


Categories of Android applications
There are many android applications in the market. The top categories are:
  • Entertainment
  • Tools
  • Communication
  • Productivity
  • Personalization
  • Music and Audio
  • Social
  • Media and Video
  • Travel and Local etc.


Android  Architecure :
android architecture or Android software stack is categorized into five parts:
  1. linux kernel
  2. native libraries (middleware),
  3. Android Runtime
  4. Application Framework
  5. Applications




1) Linux kernel
It is the heart of android architecture that exists at the root of android architecture. Linux kernel is responsible for device drivers, power management, memory management, device management and resource access.


2) Native Libraries
On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType, SQLite, Media, C runtime library (libc) etc.
The WebKit library is responsible for browser support, SQLite is for database, FreeType for font support, Media for playing and recording audio and video formats.


3) Android Runtime
In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is responsible to run android application. DVM is like JVM but it is optimized for mobile devices. It consumes less memory and provides fast performance.


4) Android Framework
On the top of Native libraries and android runtime, there is android framework. Android framework includes Android API's such as UI (User Interface), telephony, resources, locations, Content Providers (data) and package managers. It provides a lot of classes and interfaces for android application development.


5) Applications
On the top of android framework, there are applications. All applications such as home, contact, settings, games, browsers are using android framework that uses android runtime and libraries. Android runtime and native libraries are using linux kernal.

Android Core Building Blocks:


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.


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 defines the overall structure and information about the application.
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.


Introduction ON 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:
Components
Description
Activities
They dictate the UI and handle the user interaction to the smart phone screen
Services
They handle background processing associated with an application.
Broadcast Receivers
They handle communication between Android OS and applications.
Content Providers
They 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 AppCompatActivity {

}
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 BroadcastReceiverclass and each message is broadcaster as an Intent object.
public class MyReceiver  extends  BroadcastReceiver {
  
   public void onReceive(context,intent){}

}
Content Providers:
A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolverclass. 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(){}

}
We will go through these tags in detail while covering application components in individual chapters.
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 −


Components
Description
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.


First of all make  ENVIRONMENT  SETUP  :
install  jdk1.8.0 from 

"http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"


SEt variable nameS STEP BY STEP:

(a)GO TO FOLLOWING PATH :

FIRST OPEN CONTROL PANEL

(b) then go to Control Panel\All Control Panel Items\System  &

click on Advance system setup

after  that click  on Environment Variables

then click on New  and  add variable name & variable value:

(c)variable name:JAVA_HOME
variable value:
C:\Program Files (x86)\Java\jdk1.8.0_40

(1)Android studio Configuration (click here to procedure)
(2)Sdk  Manager(click here to see procedure)


---------------------------------------------------------------------------------------------------------------------- 
Now See Below steps  that will guide you  "How to  Develop a simple "HELLO WORLD!" APPLICATION :
----------------------------------------------------------------------------------------------------------------------
(1)OPEN ANDROID STUDIO & GO TO FILE MENU CLICK ON NEW & THEN CLICK ON NEW PROJECT:


(2)THEN ENTER YOUR APPLICATION NAME &  CLICK ON NEXT:

(3)THEN SELECT MINIMUM SDK   VERSION & THEN CLICK ON NEXT:


(4)THEN CLICK ON BLANK ACTIVITY:



(5)THEN ENTER YOUR ACTIVITY NAME ,LAYOUT NAME ,title, menu resource name & click on finish


(6)NOW CLICK ON PROJECT  ON  LEFT HAND SIDE UNDERSTANDING DIRECTORY STRUCTURE OF PROJECT  :




Details About all directories & Files :

app
Application module directories and files.

res/
Contains application resources, such as drawable files, layout files, and string values in the following directories.

res/drawable-hdpi
This is a directory for drawable objects that are designed for high-density screens.

res/layout
This is a directory for files that define your app's user interface.XML files that are compiled into screen layouts (or part of a screen)

res/values

This is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions.

AndroidManifest.xml :
The  control file that describes the nature of the application and each of its components. For instance, it describes: certain qualities about the activities, services, intent receivers, and content providers; what permissions are requested; what external libraries are needed; what device features are required, what API Levels are supported or required; and others.


(1)write    code   for   MainActivity.java     file   :
package helloworld.test.om.com.helloworld; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);     } }
(2)Then   write   code   for    activity_main.xml   file:
<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout

    xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"

    android:layout_height="match_parent" android:fitsSystemWindows="true"

    tools:context=".MainActivity">



    <android.support.design.widget.AppBarLayout android:layout_height="wrap_content"

        android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">



        <android.support.v7.widget.Toolbar android:id="@+id/toolbar"

            android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"

            android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />



    </android.support.design.widget.AppBarLayout>



    <include layout="@layout/content_main" />



    <android.support.design.widget.FloatingActionButton android:id="@+id/fab"

        android:layout_width="wrap_content" android:layout_height="wrap_content"

        android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin"

        android:src="@android:drawable/ic_dialog_email" />



</android.support.design.widget.CoordinatorLayout>
(3)Then write code for content_main.xml   file :
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"

    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    android:paddingBottom="@dimen/activity_vertical_margin"

    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    tools:showIn="@layout/activity_main" tools:context=".MainActivity">



    <TextView android:text="Hello World!" android:layout_width="wrap_content"

        android:layout_height="wrap_content" />

</RelativeLayout>


OUTPUT:





Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

1 comments:

  1. Having read this I believed it was very enlightening. I appreciate you spending some time and effort to put this information together on Android Training in Gurgaon NCR as it will help developers build great apps is what the Android Developer do. it was still worthwhile!

    ReplyDelete

 

© 2013 ANDROID TRAINING AT VISSICOMP BY OM SIR. All rights resevered. Designed by Templateism

Back To Top