• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Difficulties with Intents

AndDevloper

Lurker
Apr 20, 2010
3
0
Hey,
I am facing some difficulties with intents. I will post all of my question here
1. When I pass an intent from one activity from one activity to another, is it necessary for the activities to have an intent filter. I mean can there be no intent filter at all?

2. Can I send string data though an Uri? If yes, how can I extract it at the other activity?
 
Hi AndDevelopr

1. If the two activities are in the same application, there is no need to have an intent filter in the activity being launched if you are using startActivity()

But if you are broadcasting an intent, then whatever activity needs to be 'listening' for the intent would need an intent filter - so that the Android OS knows which activity to wake up and give the message to.

It's a bit like the difference between calling a function direct, and broadcasting an event. If you are broadcasting an event, something else needs to have registered itself as a listener to pick up the message. But if you are calling a function direct, you are triggering it directly.

2. You can add extras data to the intent using the putExtras() method
Intent | Android Developers
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones