In this post, you will learn how to create another activity in Android Studio. This method will add activity details in AndroiManifest.xml. Hence, there is no chance for ActivityNotFoundException.
Let’s create a new activity…
Right click on project package (here com.androidride.createactivity3) in App-> Java. and select New -> Activity -> Empty Activity/Blank activity.
First of all, make sure you are in Android view in the project explorer. Some views don’t have new activity option. If you are in other views, Just click on the downward arrow and choose Android from the given options.
It’s not a problem if you don’t see Empty Activity option. In older versions of Android studio, you might find Blank activity option. Both of them are the same just a name difference. Don’t use Basic activity now because that’s the advanced version of Empty Activity/Blank activity and contains Floating action button.
Enter the Activity name and click Finish.
Enter your activity name, at the same time layout layout name automatically fills up for you if Generate layout file checkbox is checked.
Then Backwards compatibility(AppCompat) option will give the app a certain look in almost all devices, at the same time your activity will extend AppCompatActivity class. For a beginner like you, you can leave the option as empty that cause your activity to extend Activity class and Click Finish.
Your activity files are created. congrats…
You can also create another activity in the Android Studio using the File menu option.
File -> New -> Activity -> Empty Activity & step 2.
But the First method will be easy and quick when you are coding…