I have two modules in my android studio project. One module displays "Hello World" on screen, and the other module displays "Hello Module" on screen. How to decide, which module to run when the app launches. Apparently "Hello Module" is getting displayed on screen. How to use the other module by default on launch of the app.
-
By module you mean `Activity`? – Veneet Reddy Sep 20 '17 at 21:31
-
No. Module has its own activities, and manifest files. – Potluri Sai Kranti Kiran Sep 20 '17 at 21:38
3 Answers
Before the apk is generated, all the manifests in your project are combined in a process called as manifest-merging. So you should be able to change launcher activity by moving the following intent-filter from your old launcher activity to the new launcher activity:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
- 2,419
- 1
- 21
- 37
Since Veneet Reddy has given the correct idea about your problem, I'm about to give you this solution in the manifest file do it like this :
<activity android:name=".YourDesiredActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This is the way to do this. However the Manifest file will be seen in the android studio in your left window pane and do remember to choose the Android option from above the menu See the image you'll get a better idea.
Happy Learning!
- 7,392
- 8
- 44
- 82
Every module has a build.gradle file inside. The module which has apply plugin: 'com.android.application' in it's corresponding build.gradle file is supposed to be the base module of the application.
A module can have more than one activity. The AndroidManifest.xml file inside the base module should have it's activities in there. The activity we need to run on app starting has to contain the following codes inside the opening and closing tags of the activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
- 147
- 10