Sorry for this really late reply..........
What i get from your query is that it is related to how exactly the
broadcast receiver working. So this what really happens when you
register the receiver :-
the receiver gets registered in some "file or registery file" of the
Android OS. E.g you register a receiver for the EVENT that a SMS has
been received. Now since you register the receiver for this
ACTION_EVENT the Android OS checks its registry file to know which all
receivers have to be notified. Each such broadcast receiver's object
is instantiated in some order and the objects reference is held with
the system itself. The broadcast receiver objects onReceive() method
gets executed in which what ever the coder writes gets executed as
longs as the execution is within 5 sec. Now as for the receiver when
registered in any activity etc it lifecycle is governed by the
activity's lifecycle i.e as long as the activity is alive the receiver
will get executed if an EVENT occurs. When registered in Manifest the
lifecycle is forever.
Hope clears up some fog.

nep0x wrote:
> Hi
>
> I m trying to understand the use of the broadcast receiver and the way
> of activate it. There's two ways isn't it? Register it from an
> activity or declare it in the manifest. So my question is: If i code a
> broadcast receiver which is watching incoming messages and i register
> it in the manifest, when a message comes my broadcast receiver will
> catch it although any activity of my app had registered it. In a
> nutshells, i dont have to activate it so it works, only register it
> either in the manifest or in an activity.
>
> thank you
>
> On 22 mar, 18:40, Mark Murphy <[email protected]> wrote:
> > Ant wrote:
> > > Now I have abroadcastreceiverwhich has beenregisteredthrough
> > > manifest file and not through the java code, and need to unregister
> > > thebroadcastreceiverfrom the java code. Since this, i think would
> > > need a reference to System context that instantiates thebroadcast
> > >receiver.
> > > Is it possible.
> >
> > No. You should be able to disable your component via PackageManager, though.
> >
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://twitter.com/commonsguy
> >
> > Android Training in NYC: 10-11 April 2010:http://guruloft.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to