我正在使用异步任务来创建加载屏幕,但是当我想将意图传递给主要活动时,应用程序崩溃......这里有一些代码:
public class StartActivity extends Activity {
protected boolean _active = true;
protected int _splashTime = 5000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loading_screen);
Thread splashThread = new Thread() {
@Override
public void run(){
try {
int waited = 0;
while(_active && (waited <_splashTime)) {
sleep(100);
if(_active) {
waited +=100;
}
}
} catch(InterruptedException e) {
} finally {
startActivity(new Intent("HNappActivity"));
finish();
}
}
};
splashThread.start();
}
这是清单:
<activity
android:name=".StartActivity"
android:label="@string/title_activity_hnapp" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="HNappActivity"></activity>
日志猫:
09-24 20:47:06.841: E/AndroidRuntime(556): FATAL EXCEPTION: Thread-10
09-24 20:47:06.841: E/AndroidRuntime(556): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=HNappActivity }
09-24 20:47:06.841: E/AndroidRuntime(556): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
09-24 20:47:06.841: E/AndroidRuntime(556): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
09-24 20:47:06.841: E/AndroidRuntime(556): at android.app.Activity.startActivityForResult(Activity.java:2827)
09-24 20:47:06.841: E/AndroidRuntime(556): at android.app.Activity.startActivity(Activity.java:2933)
09-24 20:47:06.841: E/AndroidRuntime(556): at sk.ecopress.hn.android.StartActivity$1.run(StartActivity.java:37)
StartActivity 类首先启动,它显示加载屏幕,然后它应该将意图传递给主要活动,但它崩溃了。