2017-12-25 1 views
-2

도움이 필요합니다. 내 앱에 문제가있다. 처음에 스플래시 화면을 넣고 싶습니다. 나는 그것을 전에했다. 새로운 프로젝트에서 코드, 레이아웃 및 모든 작품을 완벽하게 만들었습니다! 코드를 응용 프로그램의 휴대 전화와 레이아웃에서 실행하면 응용 프로그램이 오류없이 완벽하게 실행됩니다. 하지만 내 전화로 열면 중지되고 열리지 않습니다 !!! 뭔가 제안 할 수 있니?앱 시작시 스플래시 화면

내 안드로이드 manifest.xml :

 android:name=".activities.SplashScreenActivity" 
     android:label="@string/splash"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
+0

오류 로그를 표시하십시오. info. – KeLiuyue

+0

android studio에서 오류가 발생하지 않습니다. 내 응용 프로그램이 내 응용 프로그램이 열리면 내 휴대 전화에서 열리려고 할 때 내 응용 프로그램이 제대로 실행됩니다. 그리고 나는 새로운 프로젝트 개미에 내 스플래시 스크린을 고치려고 노력했다. 내 휴대 전화로 실행하면 완벽하게 작동한다. –

답변

0

것은 당신이 당신의 SplashScreenActivity에서 주요 활동을 시작하려는 가정. 당신의 SplashScreenActivity의에서 onCreate()에서

는 :

Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class); 
startActivity(intent); 
finish(); 

첫 번째 두 라인은 텐트를 통해 주요 활동을 시작, 당신은 MainActivity에서 다시 갈 수 있도록 제 3 라인은 SplashScreenActivity을 죽인다.

+0

인 텐트 intent = 새 인 텐트 (SplashScreenActivity.this, LoginActivity.class); startActivity (intent); SplashScreenActivity.this.finish(); –

+0

이것은 내 코드입니다. LoginActivity는 내 스플래시 화면 이후에 열고 싶은 다음 레이아웃입니다. –

+0

SplashScreenActivity.this.finish(); 중복이다. – ReverseEffect

0
public class SplashScreenActivity extends AppCompatActivity { 
private int SLEEP_TIMER = 3; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    setContentView(R.layout.activity_splash_screen); 

    View imageView = findViewById(R.id.imageView); 

    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fade); 

    imageView.startAnimation(animation); 
    getSupportActionBar().hide(); 
    LogoLauncher logoLauncher = new LogoLauncher(); 
    logoLauncher.start(); 


} 

private class LogoLauncher extends Thread { 
    public void run() { 
     try { 
      sleep(1000 * SLEEP_TIMER); 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
     } 

     Intent intent = new Intent(SplashScreenActivity.this,LoginActivity.class); 
     startActivity(intent); 
     SplashScreenActivity.this.finish(); 
    } 
} 
관련 문제