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.
Step 2: AndroidManifest.xml
The following code will set default activity for android application
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 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).