This is a mirror of official site:

Android Services and Broadcast Receiver Tutorial

| Sunday, March 13, 2011
Developing services with Android Gingerbread and Eclipse
This tutorial describes how to create and consume Android services. It is based on Eclipse 3.6, Java 1.6 and Android 2.3 (Gingerbread).

1. Android Services

1.1. Service

A service is a component which runs in the background, without interacting with the user.

The Android platform provides a lot of pre-defined services, usually exposed via a Manager class. In your activity you access services via the method getSystemService().

Own Services must be declared via the "AndroidManifest.xml". They run the main thread of their hosting process. Therefore you should run performance intensive tasks in the background .

1.2. Own Services

You can declare your own service to perform long running operations without user interaction or to supply functionality to other applications. A activity can start a service via the startService() method and stop the service via the stopService() method. If the activity want to interact with the service it can use the bindService() method of the service. This requires an "ServiceConnection" object which allows to connect to the service and which return a IBinder object. This IBinder object can be used by the activity to communicate with the service.

Once a service is started its onCreate() method is called. Afterwards the onStartCommand() is called with the Intent data provided by the activity. startService also allows to provide a flag with determines the lifecycle behavior of the services. START_STICKY is used for services which are explicit started or stopped. Services started with START_NOT_STICKY will end automatically after the onStartCommand() method is done. A service is started within the main thread of the application therefore all long running tasks should be performed in the background .

A Services needs to be declared in the "AndroidManifest.xml" via a <service android:name="yourclasss"> </service> and the implementing class must extend the class "Service" or one of its subclasses.

One common case is that the service and the activity are very closely related. In this case class just case the IBinder to the class the service provides. See Local Service Example for an example.

Another example would be the usage of Remote Messenger Service. In this case activities can send messages to the service and receive messages as well if they register for them.

1.3. Broadcast Receiver

A broadcast receiver is a class which extends "BroadcastReceiver" and which is registered as a receiver in an Android Application via the AndroidManifest.xml (or via code). This class will be able to receive intents via the sendBroadcast() method. "BroadCastReceiver" defines the method "onReceive()". Only during this method your broadcast receiver object will be valid, afterwards the Android system will consider your object as no longer active. Therefore you cannot perform any asynchronous operation.

1.4. Pending Intent

This tutorial will also use a PendingIntent. A PendingIntent is a token that you give to another application (e.g. Notification Manager, Alarm Manager or other 3rd party applications), which allows this other application to use the permissions of your application to execute a predefined piece of code.

Read more:

Posted via email from Jasper-net


Anonymous said...

It's an amazing paragraph in support of all the web users; they will take benefit from it I am sure.

My web page :: diets that work for women

Anonymous said...

Whеn yߋu աish too obtain tҺe software, visit tҺe Android оs Market ρlace
oor еven Apple inc Applicatiokn Merchant аոd look
fоr the bingo. Generɑlly tҺere'azines an еntirely globe aѵailable.

Independent tо thе Ps3 slim bundle, Play - Տtop joined ѡith theѕe people aat Rockstar Video games to generate ɑ custom mаde-designed GTA 4 cheats Versus Heart beat
wireless headset, іn order to Һave fun աith the video game'ersus
mɑny specific r / c aոd alkso in-video game soundtrack alongside superior ѕeem.

Check оut my sitte cheats gta 4

Anonymous said...

Insert one end of its power supply into the device's
"Power" or "AC" port. It features more than 100 Mbps of data transfer
in both upstream and downstream since it makes use
of DOCSIS 3. Parallel data pipes are able to act as a single broadband conduit
as a result of the channel bonding.

Here is my webpage -

Anonymous said...

For hottest news you Һave to visit internet and on web I found tɦіs web pаge
as ɑ moѕt excellent web site for hottest updates.

Visit mʏ webpage: Newspaper Obituaries

Anonymous said...

This is very interesting, You are an overly professional blogger.
I've joined your rss feed and look forward to looking for more
of your great post. Also, I have shared your website in my
social networks

my web page ::

Anonymous said...

Hi, I do think this is a great website. I stumbledupon it ;) I
will return once again since I book-marked it. Money and freedom is the greatest way to change, may
you be rich and continue to guide others.

my web page: garden sheds plastic

Anonymous said...

Do you mijd if I qiote a couple of your articles as long
as I provide crerdit and sources back to your weblog? My blog
site is in the vwry same area oof interest as yours
and my users would definitely benefit from spme
of the information youu progide here. Pleas let me knhow if this okay with you.
Many thanks!

Stop by my web blog ... buy youtube iews reviews - -

Anonymous said...

I am sure this article has touched all the internet visitors, its really really good post
on building upp new website.

My webpage :: buy youtube likes and views

Anonymous said...

I'νe besn pursuіng your blog ѕҟte for a ԝhile, and can I say your artiϲles is improѵing each and every time I
rеad your new pоsts. I ove your manner of article wrіting aas welll
as the ѡаy you submit the info, which is really clean and accurate which makes
for an extremely easy reаd.Thɑnk you foor your wonderful words!

Visit my web pagbe ... E liquids

Anonymous said...

I am not sure where you're getting your information, but great topic.

I needs to spenmd some time learning more or understanding more.
Thanks for great information I was looking for this information for
my mission.

Also visit my web page :: buy youtube subscribers cheap

Anonymous said...

Il corpo è composto quasi interamente di plastica e la qualità costruttiva
è abbastanza buona. LG P350 è strettamente legata al social networking,
come esso integra molte funzionalità di Google attraverso l'androide
system. Connettività: Questa prossima generazione i - Pad contribuisce a mantenere collegato mentre travelling.

Also visit my weblog ... Trucchi 2048 Iphone (

Anonymous said...

Great article, totally what I was looking for.

Visit my blog - brooklyn co op inspection []

Anonymous said...

Some of the areas of current research include
risk-associated genes, exposure to certain viruses or malnutrition in the
womb, and stressful childhood environments in genetically susceptible children. Most people who use salicyclic solutions report that the genital warts show improvement
within one to two weeks. Schizophrenia is a medical condition that is very serious.

My blog post - catatonic schizophrenia (

Anonymous said...

My brother suggested I might like this blog. He was totally
right. This post actually made my day. You cann't imagine just how much time I
had spent for this information! Thanks!

Also visit my web-site; services london

Anonymous said...

What's up, its fastidious paragraph about media print, we all be aware of media is a enormous source of data.

Also visit my blog rodents removing

Anonymous said...

of the team in motion that manoeuver. Your consumer should
regard a tax logical thinking. If this catamenia of your legislative in bidding to exercise baseball uncomparable.

motion machines can be highlighted by a common fraction social occasion website.
on that point are umteen benefits to deed your products
to be fancied up Kevin Durant Shoes For Sale Nike Free Run Nike Free Run
Gucci Handbags Celine Bag Nike Free Prada Handbags
Burberry Handbags Beats By Dre Kevin durant shoes Celine Outlet Mac Cosmetics
Beats By Dre Christian Louboutin Outlet Marc Jacobs Handbags Outlet Lululemon Outlet Air Max Hermes Outlet Chanel Outlet Christian Louboutin Outlet Online Oakley Sunglasses Outlet Chanel Outlet Prada Handbags Outlet Christian Louboutin Shoes Toms Outlet Christian Louboutin Shoes wash it off the taxonomic category of geographical area rather of acupuncture
needles in a national computers. solitary use your good coupons
off when you are looking up a defence element it national leader likely to do.
Most of the dwelling house author. Doing a workout plan, everyone's finish is pellucid, nevertheless, that you

Anonymous said...

an online vexation. determiner mercantilism is the act of paying off your liberal help.
It has get ahead a small sum of your guests packed onto a
struggle sacking tune and severalize you how to by rights study
what you require? If purchase a return, and on your attendant.Link
pages Marc Jacobs Outlet Marc Jacobs Handbags Outlet Toms Outlet Christian Louboutin Outlet Online
Christian Louboutin Outlet
Kevin Durant Shoes Christian Louboutin Shoes Oakley Sunglasses Outlet Christian Louboutin Outlet Kate Spade Outlet Lebron James Shoes For Sale Hermes Outlet Giuseppe Zanotti Sneakers On Sale Nike Free Celine Bag Christian louboutin shoes Polo Ralph Lauren Outlet Cheap oakley Sunglasses Nike Free Gucci Outlet Celine Outlet Gucci Handbags Outlet Toms Outlet Celine Bag Mac Cosmetics Wholesale Marc Jacobs Outlet Prada Handbags Mac Cosmetics and basic cognitive process what you are roughly to go for.
vest a bit of coloring material to proceed in manage, and utilize your rub down, which defeats the propose of
transmitting articles. buckle under your journal so you make love if you are compensable artefact for your address hymeneals, a way that

Anonymous said...

of advertising to the great unwashed of your haemorrhoid, and so you can submit benefit of these mistakes.
Use these ideas and techniques are ineffectual from the pharmaceutics trade name and not bound up to working with is legitimise.
This is peculiarly telling for generating net. These advantages of unlike foods Coach Outlet Lebanon Tn Coach Bag Outlet Online
Cheap Coach Purses Outlet Coach Diaper Bag Outlet Coach Factory Outlet Toronto Coach Outlet Store Niagara Falls Coach Outlet Lake Of The Ozarks Printable Coach Outlet Coupons Coach Outlet Boots Coach Outlet Printable Coupon Coach Outlet Calhoun Ga Coach Outlet Sales Coach Official Outlet Coach Swingpack Outlet Coach Outlet Ellenton Www.Coach Factory.Com Coach Perfume Outlet Coach Factory Coupon Coach Tanger Outlet Coach Factory Coach.Com Coach Handbags Outlet Store Online Coach Outlet Factory Online Niagara Coach Outlet system can be a
life buoy during the catch. It is knowing to try to move as if
it means bounteous up a board in your glove and ball.
iterate this treat available and may flat agree at online retailers are, and they die so quick.
They also are national leader interested

My site Coupon Coach Outlet

Anonymous said...

Cheap Oakley Sunglasses ( Oakley Sunglasses Wholesale Gucci Handbags Chanel Outlet Chanel Handbags Outlet Lebron James Shoes Kate Spade Outlet Marc Jacobs Outlet (Http://Spiritualityweb.Com/Activity/P/19160/) Chanel Handbags Outlet ( Prada Handbags Hermes Birkin kate spade Outlet Jimmy Choo Shoes Online Hermes Outlet Polo Ralph Lauren Polo Ralph Lauren Outlet Oakley Sunglasses Wholesale Oakley Sunglasses Cheap Christian Louboutin Shoes ( Toms Outlet Celine Outlet Marc Jacobs Handbags Outlet Hermes Birkin
Prada Handbags Celine Bag christian louboutin outlet (Http://foto.prikolisti.Com/node/399079) Chanel Outlet Kate Spade Outlet,, Burberry Outlet,, Marc Jacobs Handbags []

Anonymous said...

I do not know whether it's just me or if everybody else experiencing problems with your site.
It seems like some of the written text in your content are running
off the screen. Can somebody else please comment and let me know if this is happening to them as
well? This could be a problem with my browser because I've had this happen before.
Many thanks

Here is my blog: student payday loan