Does startActivity send a broadcast?

Yes and yes, as that is essentially what is happening when you start an Activity. You are broadcasting an Intent, which is captured by another Activity with the appropriate IntentFilters set.

Can you give me an example of the appropriate IntentFilters if I call something like startActivity(new Intent("com.example. Class"))? I'm curious if I can register a receiver and capture the intent...thanks!

– user235925 Jun 29 at 5:59 You wouldn't use intent filters in that case, when the broadcast target is explicitly specified (as package/class). I'm not 100% sure, but I think the only way to capture an Intent with a Receiver in that fashion is to make the Receiver itself the target... but you wouldn't be starting an activity doing it that way. What exactly are you trying to do?

– ErikR Jun 29 at 6:22 I'm trying to register a receiver to let me know when the current foreground activity changes. I need to be able to do this without changing the base class of any activities...basically I want a global event to be fired when the foreground activity changes within my app. – user235925 Jun 29 at 6:24 what also could be a big help to me is if you knew a way to get a handle to the context in a foreground activity, different question but related to what I'm trying to do – user235925 Jun 29 at 6:27 A receiver is going to be overkill for that.

They're generally used to listen for events outside of the application (incoming call, screen off, etc). For your global event, you could create a subclass of Application with static method(s) that are called by Activity-level lifecycle methods (onPause, onCreate, etc). Specify your Application subclass in the AndroidManifest.

Xml file - ex. Application android:name=". MyApplication" ... > and you should be good.

– ErikR Jun 29 at 7:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions