2013-09-28 91 views
0

我知道這是一個常見問題,但無法找到解決方案。我試圖做出5秒後開始的意圖。所以當應用程序啓動時,一個屏幕 - 5秒睡眠 - 其他屏幕。沒有錯誤,只有其他班級沒有出現。線程休眠後Intent無法啓動

該應用程序啓動頭等艙,名字是Acilis.class

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.acilis); 
    Thread sayac = new Thread(){ 
     public void baslat(){ 
      try { 
       sleep(5000); 
      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } finally { 
       Intent intent_basla = new Intent("android.example.CINSIYET"); 
       startActivity(intent_basla); 
      } 
     } 
    }; 
    sayac.start(); 
} 

我也試過

Intent intent_basla = new Intent(Acilis.this, Cinsiyet.class"); 

和XML文件

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/Theme.Light.NoTitleBar" > 
    <activity 
     android:name="com.example.Acilis" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name="com.example.Cinsiyet" 
     android:label="@string/app_name" 
     > 
     <intent-filter> 
      <action android:name="android.example.CINSIYET"></action> 

      <category android:name="android.intent.category.DEFAULT"/> 
     </intent-filter> 
    </activity> 

回答

2
final Handler handle = new Handler(); 
     Runnable delay = new Runnable() { 
      public void run() { 

      Intent intent= new Intent(Main.this,bla.class); 
          startActivity(intent); 
      } 
     }; 
     handle.postDelayed(delay,5000); 
+0

感謝的人,解決了! –

+0

高興地幫助:) –