Android Essentials → Android Studio – Creating Empty Activity Project – Camposha

Android Essentials

Android Essentials

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.

  1. First create an empty project in android studio. Go to File –> New Project.
  2. Type the application name and choose the company name.
    New Project Dialog
  3. Choose minimum SDK.
    Choose minimum SDK
  4. Choose Empty activity.
    Choose Empty Activity
  5. Click Finish.

This will generate for us a project with the following:

No. Name Type Description
1. activity_main.xml XML Layout Will get inflated into MainActivity View.You add your views and widgets here.
2. 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">
                <action android_name="android.intent.action.MAIN" />
                <category android_name="android.intent.category.LAUNCHER" />

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.

Leave a Reply

Your email address will not be published. Required fields are marked *