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
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).