Android Studio – Creating Empty Activity Project
How to Create an Empty Activity in Android Studio
How to Create a Project in android studio with Empty Activity template. We see how to use Android studio to create an empty activity.
Empty Activity is just a template for android development. It is the easiest template to get started with as it generates for us a single java file and a single xml layout file.
Here’s the process.
- First create an empty project in android studio. Go to File –> New Project.
- Type the application name and choose the company name.
- Choose minimum SDK.
- Choose Empty activity.
- Click Finish.
This will generate for us a project with the following:
|1.||activity_main.xml||XML Layout||Will get inflated into MainActivity View.You add your views and widgets here.|
|2.||MainActivity.java||Class||Your Launcher activity|
The activity will automatically be registered in the android_manifest.xml. Android Activities are components and normally need to be registered as an application component.
If you’ve created yours manually then register it inside the
<application>...<application> as following, replacing the
MainActivity with your activity name:
<activity android_name=".MainActivity"> <intent-filter> <action android_name="android.intent.action.MAIN" /> <category android_name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
You can see that one action and category are specified as intent filters. The category makes our MainActivity as launcher activity. Launcher activities get executed first when th android app is run.