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

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)

Related

Error running 'splash': The activity must be exported or contain an intent-filter

I added a splash screen to my project after MainActivity. I guess it should be start first. How can i set it as first ? Here is my manifest.xml.
`
<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/AppTheme">
<activity android:name=".splash"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>`
You should switch intent-filter from MainActivity to splash.
Below you will find the solution:
<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/AppTheme">
<activity android:name=".splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
</application>
Don't forget to extend AppCompatActivity in splash.
Also, I recommend to rename splash to SplashActivity

How to fix Android manifest.xml in android studio to enable indexing?

App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter. See issue explanation for more details. less... (Ctrl+F1)
Inspection info:Adds URLs to get your app into the Google index, to get installs and traffic to your app from Google Search.
But I Have already considered one activity with an action view intent filter.
Please help.
<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/AppTheme">
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity"
android:parentActivityName=".StartActivity"/>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity"
android:parentActivityName=".StartActivity"/>
</application>
Add android.intent.action.VIEW into your launcher activity like below.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Just add inside application tag
<application
tools:ignore="GoogleAppIndexingWarning">
<application
android:allowBackup="true"
tools:ignore="GoogleAppIndexingWarning" **// Add this Statement Here,**
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity"
android:parentActivityName=".StartActivity"/>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity"
android:parentActivityName=".StartActivity"/>
</application>

Adding multiple application class in AndroidManifest

My android app was needed to add multiDexApplication support. But Now I need to add another custom application class. How can I do that?
//Here's My manifest code:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:largeHeap="true">
<activity
android:name=".HomeActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PostActivity"></activity>
</application>
//How can I add my .myApp application class to this?
No, That is not possible.
If u need to create two app, set MAIN, LAUNCHER intent filter to two activities
like,
<activity
android:name=".HomeActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
>
<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"
android:theme="#style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Cannot change intent filter in android manifest

I have 3 activities in this android studio project. I'm tasked with starting them each separately by moving the intent filter into the activity, however I'm unable to start one of my activities. The same activity doesn't have a /activity> closing tag and I'm not sure why. Any help would be greatly appreciated.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sean.lab1">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".ListItemsActivity"></activity>
</application>
</manifest>
I am able to move the intent tag to my ListItemsActivity and it will start, but I am not able to move the intent filter tag to my LoginActivity, nor does LoginActivity have a closing </activity> tag.
Here is what you want to do
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".StartActivity">
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ListItemsActivity"></activity>
</application>
Try this.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".StartActivity"></activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ListItemsActivity"></activity>
</application>

Activity does not start, but another activity work fine

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.

Categories

Resources