<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="App Name"
android:roundIcon="@drawable/logo"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/maintheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:icon, android:allowBackup"
>
this activity is splash screen activity below
<activity
android:name=""
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
this activity is Folder activity activity below
<activity
android:name= ""
android:theme= ""
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true">
</activity>
<activity android:name="" android:theme=""/>
<activity android:name="" android:theme="" android:configChanges="orientation|keyboardHidden|screenSize"/>
</application>
the problem is when the app run it show the splash screen and then it show the app keep closing,it doesn't start the main activity. can i make the android manifest to make the splash screen show first and then the start main activity
CodePudding user response:
You cannot use your manifest for this, you need to use an Intent.
Code Example that you need in your SplashScreen Activity:
Intent intent = new Intent(SplashScreen.this, YOURNEXTCLASS.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
CodePudding user response:
Make Sure Your compileSdkVersion 31 and targetSdkVersion 30.
CodePudding user response:
You can switch activities only from the java files.
Implement this in your OnCreate
method.
SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
startActivity(intent);
finish();
}
}, 2000); ////wait 2s before doing the action
}
AndroidManifest.xml
<activity
android:name=".ui.activities.SplashActivity"
android:exported="true"
android:theme="@style/SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activities.MainActivity"
android:exported="true"/>