Activity does not start, but another activity work fine - android

I have two activities. When i mark my first activity as launcher(StartActivity) i get an error, but when i mark second activity(MainActivity) he works.
Here is code:
<application
android:allowBackup="true"
android:icon="#drawable/buisness"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="MainActivity"
android:label="#string/app_name" android:screenOrientation="portrait">
</activity>
<activity
android:name="StartActivity"
android:label="#string/title_activity_start" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
In this variant i get error.
<application
android:allowBackup="true"
android:icon="#drawable/buisness"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="MainActivity"
android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="StartActivity"
android:label="#string/title_activity_start" android:screenOrientation="portrait">
</activity>
</application>
In this variant everything its OK.

Related

How can i show my splash screen first without making in Mainacitivity

I made a splash screen class name Splash.class . I didnt make in mainacitivity so how i can I show this at first screen (Opening screen or first screen)
Manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In order to launch the splash screen first, you have to specify the type of intent by using <intent-filter>. So, adding the below attributes to the activity in your AndroidManifest.xml file will make it launch first:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In the end, your manifest will look something like this:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name=".MainActivity"
android:exported="true" />
<activity
android:name=".Splash"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</manifest>
change your manifest like this
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name="com.your.package.Splash" //put yout class here
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
First time your android will run activity with category LAUNCHER, so change your activity class in category.LAUNCHER with your class (Splash.java)

Why does the app icon not show up in Android if the MainActivity is not set as the LAUNCHER?

When I install the application on my phone , if I do not put the Main Activity as the LAUNCHER, then the application does not show up on my Home Screen.
<application
android:allowBackup="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- This is the SplashScreen -->
<activity android:name=".SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.default" />
</intent-filter>
</activity>
<activity
android:name=".SongList"
android:label="#string/app_name" >
</activity>
<activity
android:name=".DisplayLyrics"
android:label="#string/app_name" >
</activity>
</application>

Android No Launcher activity found

I am having this problem.
I created a new xml layout (splash screen) and in manifest set it as Launcher category.
I did this before tons of time but it never happened before.
When MainActivity is LAUNCHER categpry and I run Spalsh Activity via intent it works.
Doing opposite I get error No launcher activity found.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SecondActivity"
android:label="Second Activity" >
<intent-filter>
<action android:name="net.learn2develop.SECONDACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<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>
No problem in this one, but if I modify it to
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SecondActivity"
android:label="Second Activity" >
<intent-filter>
<action android:name="net.learn2develop.SECONDACTIVITY" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
I get error.
try with following
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SecondActivity"
android:label="Second Activity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="net.learn2develop.SECONDACTIVITY" /> <!--(or android.intent.action.VIEW) -->
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
try this:
<application
android:allowBackup="true"
android:icon="#drawable/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>
<activity
android:name=".SecondActivity"
android:label="Second Activity" >
</activity>
</application>

How To set UP Activities in Manifest

<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".precus"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="com.yair.guessit.PRECUS" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="Customize"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="FirstPage"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="com.yair.guessit.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
this is my manifest up there, and the app dont open .
can someone explain me how to set up the manifest with all the activites?
the precus is the first for now to open when the app open.
at the precus activity there is a intent that when the button get clicked its Customize activity.
why its not working?
change this line in your file
<action android:name="com.yair.guessit.PRECUS" />
to
<action android:name="android.intent.action.MAIN"/>
then run it.
if it work fine. then mark it as an accepted answer.
Your application has all Activities with intent-filter .Main... Let only one to have this filter, in others - just delete intent-filteres like...
<activity
android:name="FirstPage"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>

Android App has more than one launcher

So I have an app, with 2 activities. For some reason I am getting 2 launcher icons, one for each activity, but I only want one!
The Game activity had an intent-filter which i removed. I also uninstalled the app and reinstalled it from scratch but its still coming up with both launchers :(
Manifest below
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Game"
android:label="#string/title_activity_game" >
</activity>
</application>
You need to remove the label tag from your second Activity.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Game" >
</activity>
</application>

Categories

Resources