Junior — Middle
How to initiate Activity launch in an Android application?
sobes.tech AI
Answer from AI
To launch a new Activity in Android, an Intent object is used. Usually, it is done like this:
Intent intent = new Intent(CurrentActivity.this, TargetActivity.class);
startActivity(intent);
Here, CurrentActivity is the current context, and TargetActivity is the class of the Activity to be launched. You can also pass data through the Intent using putExtra methods.
If you need to get a result from the launched Activity, startActivityForResult is used (in newer APIs — Activity Result API).