Android intents
The Intent
class is appropriately named. It is a class that demonstrates the intent of an Activity
class from our app. It makes an intent clear and it also facilitates it.
All our apps so far have had just one Activity
, but many Android apps comprise more than one.
In perhaps its most common use, an Intent
class allows us to switch between Activity
instances. But of course, Activity
instances are made from classes with member variables. So, what happens to the variable's value – the data – when we switch between them? Intents handle this problem for us by allowing us to pass data between Activity
instances.
Intents aren't just about wiring up the Activity
instances of our app. They also make it possible to interact with other apps too. For example, we could provide a link in our app for the user to send an email, make a phone call, interact with social media, or open a web page in a browser and have the email app, phone call app, social...