Sobes.tech
Junior — Middle

How can a new screen or activity be launched in an Android application?

sobes.tech AI

Answer from AI

In Android, to launch a new screen (activity), the Intent class is used. You need to create an Intent, specifying the current context and the class of the activity you want to start, then call the startActivity method.

Example:

Intent intent = new Intent(CurrentActivity.this, NewActivity.class);
startActivity(intent);

If you need to get a result from the new activity, you use startActivityForResult (in older APIs) or modern APIs with ActivityResultLauncher.

Thus, launching a new screen boils down to creating and passing an Intent to the Android system.

How can a new screen or activity be launched in an… - sobes.tech