Argardor
Argardor

Reputation: 79

Make a splashscreen - Android Java

I want make a splashscreen for my app, i have follow this tutorial - http://www.coderefer.com/android-splash-screen-example-tutorial/ -.

But when i try to launch my app, i have this error :

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.srazzz.myapp.MAINACTIVITY }

In my class, i have :

Intent i = new Intent("com.srazzz.myapp.MAINACTIVITY");

My java class was named MainAcitity. And my manifest :

<activity
            android:name=".SplashScreen"
            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:configChanges="orientation|screenSize"
            android:name="com.srazzz.myapp.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAINACTIVITY" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

If i have good understand the tutorial, we need to write "MAINACTIVITY" cause of android:name in manifest.

I have try to set "MainActivity" but that don't work :

Intent i = new Intent("com.srazzz.myapp.MainActivity");

Upvotes: 1

Views: 135

Answers (2)

Gurupad Mamadapur
Gurupad Mamadapur

Reputation: 989

Change:

Intent i = new Intent("com.srazzz.myapp.MainActivity");

To:

Intent i = new Intent(getBaseContext(),MainActivity.class);

It'll work fine now.

Upvotes: 1

Spencer Williams
Spencer Williams

Reputation: 86

Remove action tag that contains MainActivity and in the new intent you also have to add the context from your splash screen activity as so

Intent i=new Intent(Splash Screensaver.this, com.srazzz.myapp.MainActivity)

Or even instead of the com.srazzz.myapp.MainActivity Just use MainActivity.class.

Then call it by

StartActivity(i) ; After your splash screen sleep timer

Upvotes: 1

Related Questions