Documente Academic
Documente Profesional
Documente Cultură
Home
About us
Contact us
Privacy Policy
Tutorials
Gadgets
Internet
Technologies
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
1/13
15/07/2015
2. Intent Filters
Lets come to the GUI part. The User Interface elements are made up the below components, which we called:
1. Views
2. Notifications
Now it is time to describe in details for each of the above components and its requirement and usages.
Android Activity
Activity is the basic building block of every visible android application. It provides the means to render a GUI.
Every screen in an application is an activity by itself. We can call each visible component as an activity in
android. Though more than one activities work together to present an application sequence, each activity is an
independent entity. Just have a look at the below image, which explains the life cycle of an activity. I will explain
the practical use of an activity, when we will develop our first Hello World application in this tutorial.
Life Cycle of an Activity in Android
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
2/13
15/07/2015
To make you understand the real usage click here for complete example.
Android Services
Service is another building block of android applications which does not provide any UI. It is a program that can
run in the background for an indefinite period. That means if we want to do a long operation (example: download
data from internet), then we need to create an Android service for this purpose.
Android Services are little bit confusing. Before going to know What is Android Service? Lets have a clear
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
3/13
15/07/2015
Using Android Service, we just inform the Android OS that, We are going to do a background
processing.
Also Android Service exposes some functionality to other applications using the bind mechanism.
Generally Android Service are of 2 types.
Started Service (Unbounded)
This type of service is created and called by Android Activities. There is no 2 way communication between
Android Activity and Service. The Activity just starts the service and does not care about the status of the
service. The Service will finish its work and automatically stops when finish its job.
Bound Service (Bounded)
This type of Android Service is for 2 way communication. Suppose an Android Activity has started a bounded
service, then Activity can be notified about the status by the service.
Dont worry we will discuss in details about Android Services with an example in the example section.
LifeCycle of a Service in Android
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
4/13
15/07/2015
To make you understand the real usage click here for complete example.
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
5/13
15/07/2015
I think the basic knowledge of these four components is good enough to start development now, the knowledge
of the means of communication between the components is also essential. So the android platform offers a new
concept of communication through intents and intent filters.
To make you understand the real usage click here for complete example.
Android Intents
Intents are messages that are passed between components. So we have a question in our mind. Is it equivalent to
parameters passed to API calls? Yes, it is close to that. However, the fundamental differences between API calls
and intents is the way of invoking it. Lets have a look at the difference between these two in below points.
1. API calls are synchronous while intent-based invocation is asynchronous (mostly)
2. API calls are bound at compile time while intent-based calls are run-time bound (mostly)
It is these two differences that take Android platform to a different league.
In simple word, the core android components of an application activities, services, and broadcast receivers
are activated through messages, called intents.
For example an activity can send an intent to the Android system which starts another activity. So an Intent is
just a way to send a message in android.
Android intents are basically 2 types in nature.
1. Implicit Intents
Implicit intents specify the action which should be performed by other components or applications.
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
6/13
15/07/2015
For Example: If you want to open an URL in a web browser from your application code, Then following code
tells the Android system how to view a webpage. Typically the web browser is registered to this Intentbut
other component could also register themselfs to this intent. That means if you have installed web browsers like
IE, Mozilla Firfox and Google Chrome, then all browsers might be registered to the intent
(Intent.ACTION_VIEW) to show a web page as per you request.
1 Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.techblogon.com"));
2 startActivity(i);
If only one component (here web browser in our example) is found, Android starts this component directly. If
several components are identifier by the Android system, the user will get an selection dialog and can decide
which component should be used for that Intent.
2. Explicit Intents
Explicit intents explicitly defines the exact component which should be called by the Android system, by using the
Java class are identifier.
The following code shows how to create an explicit intents and send it to the Android system. That means
Android system will directly execute your intent request as you requested. Explicit intents are typically used
within an application, as the classes in an application are controlled by the application developer. If you want to
open an Android Activity from another activity, then below is the code for it using an intent to do so. Also you
can send some data to that activity if required.
1 Intent i = new Intent(this, ActivityTwo.class);
2 i.putExtra("First Value", "This First Value for ActivityTwo");
3 i.putExtra("Second Value", "This Second Value ActivityTwo");
7/13
15/07/2015
Next Page
C ONNECT
Activity in android, broadcast receiver in android, content provider in android, intent filter in android, intent in
android, notification in android, Service in android, views in android
2.
3.
Abinash says:
March 29, 2013 at 12:22 pm
I am new to android development though i have 4.5 years experience in .net technologies..i find this
man named SmrutiRanjan is really a great guyits really very easy to understand..thank bro.
Cheears
Abinash Routray
Reply
4.
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
8/13
15/07/2015
If yes, may you kindly provide to some good articles or tutorials about the same?
Reply
SmrutiRanjan says:
April 5, 2013 at 5:28 am
Dear Manish,
API are just the collection of Android functions, Which has already exist with the default Android
SDK. We just need to call them in our application, so dont worry.
Reply
5.
P.S.Sanatan says:
April 12, 2013 at 7:13 am
i came across your blog and i think you can help me.I dont know about java programming and i have
basic idea about the c and c++.Then what should be the procedure for me to learn the anroid application
development.Please guide me
Thank you
Reply
SmrutiRanjan says:
April 12, 2013 at 10:29 am
Dear Sanatan,
It is not necessary to know java for android.
Just setup all android tool, then just learn some common fundamentals like activity, intent, broadcast
receiver etc. then start will hello world program
You can refer to my site, it is written in such a way that begginers can read from the top to the
bottom, which will help you to go ahead step by step.
Reply
P.S.Sanatan says:
April 16, 2013 at 10:35 am
Thank you for your valuable guidance,i am going to do the same thing as told by you and
hope you will guide in my way of learning anroid.
Thank you.
Reply
6.
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
9/13
15/07/2015
Reply
7.
8.
leela says:
May 18, 2013 at 6:07 am
hai sir good morning iam new to Android technology iam learning basics from ur website its really good
and i want to learn android technology is it good has it future for this technology i want to know please
give guidance for this and also jobs rating and openings for this technology
Reply
SmrutiRanjan says:
May 18, 2013 at 6:13 pm
Very good Android market
Reply
9.
10.
principally says:
July 24, 2013 at 9:55 pm
Awesome things here. I am very glad to peer your article. Thank you a lot and im having a look forward
to contact you. Will you please drop me a mail?
Reply
11.
Leave a Reply
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
10/13
15/07/2015
Your email address will not be published. Required fields are marked *
Name *
Email *
Website
3 = two
Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym
title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del
datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" dataurl=""> <span class="" title="" data-url="">
Post Comment
Search
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
11/13
15/07/2015
Techblogon
Follow
+1
+ 305
Like 1,859 people like this. Be the first of your friends.
Recommend on Google
Follow @techblogon
RSS Feed
Google Plus
Archives
March 2015
July 2014
April 2014
October 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
Categories
Android
Android Tutorial
Design Patterns
Displays
E-Commerce
Gadgets
Google
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
12/13
15/07/2015
Internet
Mobile Phones
Softwares
Technologies
Tutorials
Windows
Pages
About us
Contact us
Privacy Policy
Meta
Log in
Entries RSS
Comments RSS
WordPress.org
2015 Techblogon
http://techblogon.com/android-fundamentals-components-activity-service-broadcast-receiver-content-provider/
13/13