Reputation: 11
When i send a broadcast by context.sendBroadcast(intent1)
method with parameter: intent1
and start a activity by context.startActivity(intent2)
method with parameter: intent2
. What is difference between them. Are intent1
and intent2
implicit intent with define: new intent(action_do_something)
. Can anyone help me ? Thank a lot
Upvotes: 0
Views: 684
Reputation: 6034
As the names suggest, sendBroadcast will send a message to no particular recipient. It just transmits a message like a radio tower. You have to listen for broadcasts.
On the other hand, startActivity starts an activity(the onResume() of the activity will be eventually called).
Upvotes: 1
Reputation: 54692
The names are saying it all. When you send a broadcast message you need to call the sendBroadcast. but to start activity u need the other method. There is no direct comparision between these two as the purpose of these two things is totally different.
In both case the intent is used for a common reason, first two define the receiver. In the broadcast message the intent is passed to make sure which type of receiver can catch this. And for startActivity it is used to do same but for to make sure which activity will be started. and in both cases intent is used to pass data.
Upvotes: 0