how to put spalsh screen before mainActivity for me crashed

mahdi norouzi6 years ago

my code is:

public class Spalsh extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.backg);

        int secondsDelayed = 1;
        new Handler().postDelayed(new Runnable() {
            public void run() {
                startActivity(new Intent(Spalsh.this, MainActivity.class));
                finish();
            }
        }, secondsDelayed * 1000);
    }
}

manifest is:

 <activity
            android:name=".Spalsh"
            android:launchMode="singleTask" />
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTask" />

        <activity-alias
            android:name=".Launcher"
            android:targetActivity=".Spalsh">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />
        </activity-alias>

crash is:

java.lang.RuntimeException: Unable to instantiate application org.icasat.mn.GoogleMainApplication: java.lang.ClassNotFoundException: Didn't find class "org.icasat.mn.GoogleMainApplication" on path: DexPathList[[zip file "/data/app/org.icasat.mn-1/base.apk"],nativeLibraryDirectories=[/data/app/org.icasat.mn-1/lib/arm64, /system/lib64, /vendor/lib64]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:806)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5479)
    at android.app.ActivityThread.-wrap2(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1591)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:163)
    at android.app.ActivityThread.main(ActivityThread.java:6228)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.icasat.mn.GoogleMainApplication" on path: DexPathList[[zip file "/data/app/org.icasat.mn-1/base.apk"],nativeLibraryDirectories=[/data/app/org.icasat.mn-1/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.Instrumentation.newApplication(Instrumentation.java:993)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:800)
    ... 9 more