I am new to Java android development and i am trying to add splash screen before main activity so i created a splash screen class . and in my android manifest i did the following changes:
<activity
android:name="com.example.mayoenglishconversation.SplashScreen"
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="com.example.mayoenglishconversation.MainActivity"
android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
and here is the code of my SplashScreen.java file:
package com.example.mayoenglishconversation;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.PersistableBundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class SplashScreen extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle
persistentState) {
super.onCreate(savedInstanceState, persistentState);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i=new Intent(SplashScreen.this,MainActivity.class);
startActivity(i);
}
},3000);
}
}
but issue is i am stuck with the splash screen . what i am doing wrong?
CodePudding user response:
Try to change the override method protected void onCreate
instead of public void onCreate
. I faced this issue previously, It worked.
CodePudding user response:
try to use following override
method;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}