Sunday 30 November 2014

What is Fragment ?

* Fragment is a small part of Activity.

* Split the Activity into SubActivity called Fragment that fits into an Activity ( Ex. Tablet ).

* Fragment can have its Layout means Activity contains more than xml.

* Fragment mostly used in Tablet not in Cellphone.

* This Feature starts from HoneyComb ( 3.0 ).

Thursday 27 November 2014

What is Sticky Intent in Android ?

* When we have to live the intent, object of intent is live called Sticky-Intent.

* Generally OS use it at the situation where we have to broadcast everytime.

* We have not create everytime object of intent by the use of Sticky-Intent.

* Example: BatteryChanged , LocationChanged.

* For this we have not used any permission.

* It is only a feature i.e managed by OS.



BroadCast Reciever in Android

* A Broadcast Reciever is another component in Android process,along with activities,content provider and Services.

* It is a component that can respond to a broadcast message sent by a client.

* The message itself is an Android broadcast intent.A broadcast intent ( message ) can invoke more than one reciever.

* A component such as an activity or a service uses the sendBroadcast() method available on the
Context class to send a broadcast event.

* Receiving components of the broadcast intent will need to inherit from a receiver class.

* These receiving components need to be registered in the manifest file through a receiver tag to
indicate that the class is interested in responding to a certain type of broadcast intent.



Wednesday 26 November 2014

What is Intent Resolution ?

To resolute intent Action , Data and Category are used for Implicit and Component is used for
Explicit intent.

Resolution of Explicit Intent :-

Explicit intent can be resolved by Component name by creating an Object of required Class from
required Package.

Resolution of Implicit Intent:-

* To start a component with Implicit Intent it has to be registered with intent-filter.

* Intent-filter filters intent based on following criteria:-

i)- If action / category / data is missing nothing will be checked.

ii)- If category is set to default it will not be checked.

iii)- If intents action / category / data is not matching with intent-filters action / category / data ,
the intent is discarded.

iv)- if all parameters matches object of component is created and launched.


Tuesday 25 November 2014

Fields of Intent in Android.

1- Component:

i)- It specifies the component to be started.
ii)- It can be set to class or fully qualified class name.

2- Context:

It is the context in which intent will be created.

i)- For Activity: Context is " this ".
ii)- For Content Provider : Context is getContext().
iii)- For Service : Context is getApplicationContext().
iv)- For Broadcast Reciever : Context will be passed as a parameter to onRecieve() method.

3- Action:

It is a String Constant which defines unique action performed by the intent ( unique by its package name ).

4- Category:

i)- It is more information about an action.
ii)- By default category is set to "android.intent.category.DEFAULT".

5- Data:

It is type of URI that supported in the component.

Example: 

Browser supports " http " URI , Telephone supports " tel " URI.
 
* Context and Component are used for Explicit Intent and Remaining feilds are used for Implicit intent.

Monday 24 November 2014

What is an Intent in Android ?

Intent is an intention to perform an operation.

It is used for-

1- To Start Component:

i)- Activity -> StartActivity and StartActivityforResult.

ii)- Service -> bindService / StartService

iii)- BroadCastReciever -> context.sendBroadcast

2- To Transfer data from one component to another ( Custom objects can be transfered by implementing parcelable or searilizable interfaces ).

3- Types of Intents:-

 i) Explicit Intent->

It is an Intent which contains explicit info. about component which will be started using the intent.

For Example:-

a)- Intent intent = new Intent( this , TestActivity.class );

b)- Intent intent = new Intent();
intent.setClassName( "packagename", fully qualified class name );

ii) Implicit Intent->

It is an Intent which doesn't specify component info. explicitly,but "Action" is used to find the component.

For Example:-

a)- Intent intent =  new Intent("Action");

b)- Intent intent = new Intent();
intent.setAction("action"); 


Friday 21 November 2014

What is Service and its types in Android ?

1- Service is a component which doesn't have any UI.

2- It runs in Background.

3- It can Update UI elements ( UI elements of the application which is currently using the service ).

4- Services allow to share functionality among applications without creating physical copy of class.

There are two types of Services in Android :

1- Bound:

The services which is work for specific activity or application called Bound Service.

2- Unbound:

The Service which is continously running or system provides services called Unbound Service.

If we go through Life Cycle of Bound and Unbound Services,the methods are:

Bound:

i) onCreate()
ii) onBind()
iii) onUnbind()
iv) onDestroy()

Unbound:

i) onCreate()
ii) onStartCommand()
iii) onDestroy()

To know this concept in Brief , see below link
http://developer.android.com/guide/components/services.html

Thursday 20 November 2014

What are the Disadvantage of using Thread ?

1)- Background thread can't access UI elements because UI elements are created by Main Thread

and it is responsible for managing them.

2)- If the process which creates multiple threads gets killed then All the threads gets killed

immediately because threads can't run without process.


What do you mean by Async Task in Android ?

* It is a Task which provides functionality of Background and Main Thread.

* It allows application to be performed in Background thread and Update UI element in
foreground or Main thread.

* Though Async Task can perform both background and foreground operation , multiple
application needs physical copy of Async Task class in their projects.

* So Async Task can be used in Client - Server Application.

When an Async task is executed, the task goes through 4 steps:

  1. onPreExecute()
  2. doInBackground()
  3. onProgressUpdate()
  4. onPostExecute()

In Brief , you can go through this link http://developer.android.com/reference/android/os/AsyncTask.html

Wednesday 19 November 2014

How to create Content Provider and its Steps in Android ?

Content Provider is a component which

1)- hides database details ( database name , table name , coloumn info. etc.).
2)- allows application to share data among multiple application.

Steps to create Content Provider :

i)- Create C.P subclass (android.ContentProvider).
ii)- Register C.P in AndroidManifest.xml using Provider element(<Provider>).

To register Content Provider use following attributes :

1- android:name -> C.P subclass name.
2- android:authorities -> authority used for C.P
3- android:exported - >true/false.

true:-> C.P can be used in other applications.
false:-> C.P can be used in local applications ( the application which is defining C.P).

by default it is true.

URI:

i)- Stands for Universal Resource Identifier.
ii)- It is used to identify C.P uniquely in currentr device.
iii)- URI has a special format. i.e.

Content : // Authority / Path / Record Id




Monday 17 November 2014

What is Convert View and How we use it in Adapter Memory Management ?

To use Memory in Smart way we can use Convert View in Android.

- To reuse the memory for other Iterations.

- A parent View can't have once child view more than once.

Adapter Memory Management:

1)- Adapter by default creates new Object of View for every element in Array.

   - Since the Application runs on Mobile it may crash because of low memory situation.

2)- To avoid creating new object every time getView() method accepts "Convert View" as return 
    
     value of previous iteration.


3)- It is null in first iteration and from next it is the return value of previous iteration.

There are three cases to use Convert View i.e.

1- Convert View Using Single View.

2- Convert View Using a Linear Layout.

3- Convert View Using Layout Inflator.

What is Inflator in Android ?

Inflator is a Class or a component which

1- Parses XML file.

2- Creates object for elements in XML.
  - It Creates heirarchy of Objects.
  - It returns object of root element.

3- Inflator inflate XML for Layout and Menu using LayoutInflator and MenuInflator.

4- To get Layout and MenuInflator activity provides getLayoutInflator() and getMenuInflator()
     method respectivily.


Saturday 15 November 2014

What is ListView in Android ?

- ListView is a Collection or a list of Views.

- ListView requires a class which converts the Array Objects into the ListView understandable format
(View) which is called as Adapter.

- ArrayAdapter is a SubClass of  BaseAdapter which is used for converting an Array into ListView
understandable form(View).

To Create ArrayAdapter following parameters are required :

-Context :  this

-textViewResourceID : the XML file from where the ArrayAdapter should find the TextView(which is used to create an Object).

-Collection : Array/Collection of the Objects which need to be shown in the ListView.

Steps to Create ListView :

- Add ListView element in the XML file or Create an Object of  ListView class .

-Create an Object of ArrayAdapter.

-Set the Adapter to the ListView.



Friday 14 November 2014

Activity Life Cycle in Android.

There are 7 stages in Activity Life Cycle. Activity Manager  manages these activities.
It shows your activity are on which state.

7 methods are :

1- onCreate()
2- onStart()
3- onResume()
4- onPause()
5- onStop()
6- onDestroy()
7- onRestart()

Your Activity can be destroy from onStop() or onRestart().

Created: In this method activity should create its UI.

Started: In this state activity is about to start,it is completely invisible.

Resumed: In this state Activity's UI is completely visible on screen.

Paused: Activity is about to unload or cover because of another activity,in this state activity is completely visible on scree.

Stopped: Activity is unloaded or another activity has fully covered the first activity,in this state activity is
completely visible.

Destroyed: In this state activity is already unloaded and about to get destroyed.

Restarted: In this state activity is about to restart because of uncovering.

Thursday 13 November 2014

What are the components of Android ?

There are mainly 4 components i.e Activity , Service , Content Provider and Broadcast Reciever .
We can also say that they are Pillers of Android.

Some other fundamental components are View , Intent , Fragment , AndroidManifest.xml .

We have to understand all these basic concepts to build an Android Application.

1- An Activity is a User Interface(UI) concept that usually represents a single screen in your application.

2- Service is a component which doesn't have any UI , it runs in background , it can update UI elements ,
     it allows to share functionality among application without creating physical copy of class . Services are
     of two types Bound and Unbound.

3- Content Provider is a component which hides Database details(database name , table name  , coloumn
     info etc.) , it allows application to share data among multiple application . 

4- Broadcast Reciever is a component which is used to recieve broadcasted messeges sent by system
     or other applications.



Wednesday 12 November 2014

How to setup your development environment ?

To build Android applications, you need to establish a development environment.

Few steps are-

1- The Android SDK requires JDK 5 or higher ,So download the JDK and install it.
     For Windows, download JDK 6 from the oracle website.

2- After the JDK is installed, you can download the Eclipse IDE . All versions of Eclipse are available
    on  www.eclipse.org/downloads/  .

3- To build applications for Android, you need the Android SDK. The SDK comes with the base tools
     then you download the package parts that you need and you want to use, it includes emulator so
     you don't need a mobile device with the android OS to develop applications.
     You can Download the Android SDK from http://developer.android.com/sdk 

4- Now you need to install ADT ,an eclipse plugin ,it integrates with eclipse to provide facilities for
     you to create , test and debug applications.


Tuesday 11 November 2014

Architecture Of android or Android Software stack

 In Android the software stack or its architecture is combination of  Linux Kernel , Native Libraries ,

Android runtime i.e. Dalvik VM , Application Frameworks and Applications.

If you want to see in detail please go to the below link.
 
Click to see the Architecture of Android in Brief

1- Linux kernel is responsible for Memory management , File management , Scheduling , Security and other
OS duties.

2- Native Libraries are written in C/C++  includes Media , SQLite , OpenGL , Graphics etc.

3- About Dalvik VM you can see my previous post.

4- Application frameworks provides all manager for development like Activity Manager , Location Manager and Notifiction Manager.

5- And at last Applications like Camera , Gallery , Calculator etc.

Monday 10 November 2014

Delving into the Dalvik VM

Google has spent a lot of time thinking about optimizing designs for low powered handheld devices.
If you look at the list of packages in android , you will see that they are fully featured and extensive.

The key figure in Google implementation of the JVM is Dan Bornstein , who wrote the Dalvik VM.
Dalvik is the name of a town in Iceland.

Dalvik VM takes the generated java class files and combines them into one or more Dalvik Executable
(.dex) files.

The goal of the Dalvik VM is to find every possible way to optimize the JVM for space,performance,
and battery life.

Friday 7 November 2014

History of Android

In 2005 Google acquired the startup company Android Inc. to start the development of Android
platform.

The key players at Android Inc. included  Andy Rubin , Rich Miner , Nick Sears and Chris White.

The Android SDK was first issued as an "early look" release in November 2007.

In September 2008 T-Mobile announced the availablity of T-Mobile G1 , the first smartphone
based on the Android Platform.


Why Android ?


The Android Platform embraces the idea of general purpose computing for handheld devices.

It is a comprehensive platform that features a Linux based operating system stack for managing
devices,memory and processes.

Android Java libraries covers telephony,video,speech,graphics,connectivity,UI programming and a no.
of other aspects of the device.

It is built for mobile and tablet based devices. Google makes the framework available to java developers
through a Software Development Kit (SDK) called the Android SDK.

When you are working with the Android SDK you rarely feel that you are writing to a mobile device
because you access most of the class libraries that you use on a desktop or a server.