Skip to content Skip to sidebar Skip to footer

Splash And Main Activity Error

Can someone please help. After the splash activity, the main activity isn't opening up. But if I put in any other intent filter name it works Just not the main activity. Thanks in

Solution 1:

Try this in your Splash Activity..

 Intent yo = newIntent (Splash.this, MainActivity.class);
        startActivity(yo);

In your manifest file

<activityandroid:name="com.hellhog.tfreqpro.MainActivity"android:label="@string/app_name"android:screenOrientation="portrait" ><intent-filter><actionandroid:name="android.intent.action2.MAINACTIVITY" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter></activity>

delete the following lines of intent filtter

<intent-filter><actionandroid:name="android.intent.action2.MAINACTIVITY" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter>

Solution 2:

Here is what working for me perfectly !

protectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title barthis.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);  // Removes notification bar

    setContentView(R.layout.splashscreen);

    // Start timer and launch main activityIntentLauncherlauncher=newIntentLauncher();
    launcher.start();
}

privateclassIntentLauncherextendsThread {

    @Override/**
     * Sleep for some time and than start new activity.
     */publicvoidrun() {
        try {
            // Sleeping
            Thread.sleep(SLEEP_TIME*1000);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
        }

        // Start main activityIntentintent=newIntent(SplashActivity.this,FullscreenActivity.class);
        SplashActivity.this.startActivity(intent);
        SplashActivity.this.finish();
    }
}

Solution 3:

Try to use below code..

publicclassSplashScreenextends Activity {
@OverridepublicvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);
    Handlerhandler=newHandler();
    handler.postDelayed(newRunnable() {

        publicvoidrun() {
            // TODO Auto-generated method stub
            finish();
            Intentmenu=newIntent(getBaseContext(), MainActivity.class);
            startActivity(menu);
        }
    }, 3000);
}

}

It will set your SplashScreen for 3 seconds and then starts your mainactivity or whatever activity you want to start.MAy it helps you..

Post a Comment for "Splash And Main Activity Error"