2012-06-15 8 views
2

스플래시 화면을 표시하는 앱이 있습니다. 시작 화면의 활동은 단순히 1 초 동안 자고 새의 Runnable를 만든 다음 주요 활동 시작 :UI 스레드와 다른 스레드 간의 차이점

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splash); 

    UKMPGDataProvider.init(this.getApplicationContext(), Constants.DATABASE_NAME); 

    Thread splashThread = new Thread() { 
     @Override 
     public void run() { 
      try { 
       sleep(ONE_SECOND_IN_MILLIS); 
      } catch (InterruptedException e) { 
      } finally { 
       Intent intent = new Intent(SplashScreen.this, MainScreen.class); 
       finish(); 
       startActivity(intent); 
      } 
     } 
    }; 
    splashThread.start(); 
} 

인가는 확인의 주요 활동 (및 시작 화면을 제외하고, 따라서 전체 응용 프로그램)을 시작합니다 이 새로운 스레드?

Android에서 'UI 스레드'에 대해 많이 들었습니다. 이 새 스레드는 이제 UI 스레드가되거나 UI 스레드 특수한 어떤 식 으로든됩니까?

답변

1

예, 괜찮습니다. startActivity(intent)은 시스템에 주 Activity을 시작하도록 요청합니다. 실제로 호출하는 스레드에서 직접로드하지 않습니다.

0

기본적으로 안드로이드 UI 툴킷은 스레드로부터 안전하지 않기 때문에 오직 하나의 스레드 만 UI를 수정할 수있는 single-thread model입니다.

블랙 베리에서도 마찬가지입니다. Why are most UI frameworks single-threaded?

+0

좋아요.하지만 문제는 비 UI 스레드에서 액티비티를 시작했는지 또는 이것이 일어 났는지 여부입니다. – barry

관련 문제