Junior — Middle
What is the role and purpose of the Intent object in Android development?
sobes.tech AI
Answer from AI
The Intent object in Android is used to describe an intention to perform a certain action. It is used to launch application components such as Activity, Service, or BroadcastReceiver, as well as to pass data between them. An Intent can be explicit (specifying a particular component) or implicit (describing an action to be handled by any suitable component).
Example of using an explicit Intent to start another Activity:
Intent intent = new Intent(CurrentActivity.this, TargetActivity.class);
intent.putExtra("key", "value");
startActivity(intent);
Thus, an Intent is a key mechanism for communication and navigation within an Android application.