Intent i = new Intent(getApplicationContext(), ActivityTwo.class);
startActivity(i);
To call another activity in Android, you typically use an Intent. Here’s a basic example in Java:
java
// Assuming you're in the current activity
Intent intent = new Intent(this, AnotherActivity.class);
startActivity(intent);
This code creates an Intent to start the AnotherActivity
and then calls startActivity(intent)
to actually launch it.
Make sure to replace AnotherActivity.class
with the correct class name of the activity you want to start. Also, don’t forget to declare the new activity in your AndroidManifest.xml file.
Here’s an example of how you might declare an activity in the AndroidManifest.xml file:
xml
<activity android:name=".AnotherActivity" />
This assumes that AnotherActivity
is in the same package as your current activity. Adjust the package name accordingly if it’s in a different package.