2017-07-04 10 views
0

に入るが、アプリはGenymotionエミュレータまたはアンドロイド・スタジオエミュレータ両方のエミュレータ上で実行されたとき、それはほぼ完全にそれをスキップしています他のアプリケーションと完全に動作しています。わかりません?スプラッシュ画面が速すぎて表示して、スプラッシュ画面が3秒続くことになっている次のJavaクラス

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 **

+3

にコードを変更してみてください。 4秒は4000ミリ秒です – Blackbelt

+0

int secondsDelayed = 4000; * 3を削除する – yanivtwin

答えて

1

あなたのスプラッシュスクリーンコードは、ハンドラで使用される遅延beacuseこの

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); 

が好きすべきミリ秒です。

+0

わかりやすくするために、私は 'TimeUnit.SECONDS.toMillis(3)'を使います – SpaceBison

0

変更し、あなたの変数フォーム

int secondsDelayed = 4; 

から

int secondsDelayed = 4000; 
1

あなたの秒を掛ける必要があります(例:4)あなたはミリ秒単位でそれを与える必要があるため、1000

と。

は遅延はミリ秒です

@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 * 1000); 
    } 
} 
関連する問題