I have created the meat and guts of my application but I want to add a different activity that will be the starting point (sort of a log-in screen).
Couple questions
<application
android:icon="@drawable/YOUR_ICON" <!-- THIS ICON(IMAGE) WILL BE SHOWN IN YOUR APPS -->
android:label="MY APP NAME " > <!-- HERE LABEL(APP NAME) -->
<activity
android:name=".application's starting activity" <!-- (.)dot means current dir, if your activity is in another package then give full package name ex: com.xxx.Activity -->
android:label="LABEL FOR ACTIVITY "
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Yes, you use the AndroidManifest.xml
file. You can actually even have more than one launcher activity specified in your application manifest. To make an activity seen on the launcher you add these attributes to your activity in the manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In a recent project I changed the default activity in AndroidManifest.xml with:
<activity android:name=".MyAppRuntimePermissions">
</activity>
<activity android:name=".MyAppDisplay">
<intent-filter>
<action android:name="android.intent.activity.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In Android Studio 3.6; this seems to broken. I've used this technique in example applications, but when I use it in this real-world application it falls flat. The IDE once again reports:
Error running app: Default activity not found.
The IDE still showed a configuration error in the "run app" space in the toolbar (yellow arrow in this screenshot)
To correct this error I've tried several rebuilds of the project, and finally File >> "Invalidate Cache/Restart". This did not help. To run the application I had to "Edit Configurations" and point at the specific activity instead of the default activity:
It's simple. Do this, in your Manifest
file.
<activity
android:name="Your app name"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
This is easy to fix.
Run > Debug Configurations
and edit the setting. Run > Edit Configurations
select Run default Activity and it will no longer save the setting in this fashion.Just go to your AndroidManifest.xml file and add like below
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
then save and run your android project.