Android

Android | How To Set Default Activity For Android Application?

Very easy to set default activity for Android Application

Every app has a landing page we often call it homepage/ default page where we show splash animation or intro page of our app. If our app has more than one activity then we have to know how to set default activity.

In Android, you can configure the starting activity (default activity) of your application via following “intent-filter” in “AndroidManifest.xml“.

Step 1:

First you should define your activity class in Android manifest file, which is at the root of your project directory.

set default activity

Step 2: AndroidManifest.xml

 

The following code will set default activity for android application

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="utf-8"?>
    package="app.devdeeds.com.myapplication" >
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Please note:

If no activity defined in AndroidManifest.xml has such a <intent-filter> tag then you will get error “Default Activity Not Found“. This means application should at least have one default activity(home page).

About author

Rojer is a programmer by profession, but he likes to research new things and is also interested in writing. Devdeeds is his blog, where he writes all the blog posts related to technology, gadgets, mobile apps, games, and related content.

Leave a Reply

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