Issue
The splash screen is supposed to last 3 seconds but it skipping it almost entirely when the app is run on Genymotion Emulator or Android Studios Emulator both emulators are running perfectly with other applications. I don't understand?
SplashScreen.java
package com.transcendencetech.juliospizzaprototype;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
/**
* Created by Stormy Forrester on 20/03/2016.
*/
public class SplashScreen extends AppCompatActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash_screen);
int secondsDelayed = 4;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(SplashScreen.this,
SignInActivity.class));
finish();
}
}, secondsDelayed * 3);
}
}
**splash_screen,xml **
Solution
your splashscreen code should like this
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
Intent mainIntent = new Intent(SplashScreenClass.this, Homescreen.class);
startActivity(mainIntent);
finish();
// close this activity
}
}, 3000);
beacuse the delay used in handler is in milliseconds.
Answered By - AskNilesh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.