我試圖等待,直到AsyncTask會從服務器得到結果,所以主要活動將繼續,在我的啓動畫面上我有一些GUI加載進程欄等等。強制關閉AsyncTask
但是當我運行它時,我得到了力量關閉。 這裏是我的主要活動代碼:
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
new Thread() { public void run()
{
runOnUiThread(new Runnable() {
public void run() {
splash splash=(tools.splash) new splash(first.this).execute();
int waited = 0;
while(splash.running && (waited< getResources().getInteger(R.integer.splashTimeOut)))
{
try {
wait(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(splash.running) {
waited += 100;
}
// nextActivity=splash.newActivity;
}
Intent intent = null;
try {
intent = new Intent(first.this,Class.forName("activities.third"));
} catch (ClassNotFoundException e) {
// TODD Auto-generated catch block
e.printStackTrace();
}
startActivity(intent);
}
});
}
}.start();
從日誌貓
09-26 13:41:26.862: ERROR/AndroidRuntime(487): java.lang.IllegalMonitorStateException: object not locked by thread before wait()
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at java.lang.Object.wait(Native Method)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at java.lang.Object.wait(Object.java:395)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at activities.first$1$1$1.run(first.java:54)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at android.os.Handler.handleCallback(Handler.java:587)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at android.os.Handler.dispatchMessage(Handler.java:92)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at android.os.Looper.loop(Looper.java:123)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at java.lang.reflect.Method.invoke(Method.java:507)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-26 13:41:26.862: ERROR/AndroidRuntime(487): at dalvik.system.NativeStart.main(Native Method)
我認爲它有等待的東西。 希望你能幫助。
-1問你不知道問題補充logcat的56個問題 –
是的,請加logcat中之後。 – Danpe
請發佈整個代碼+日誌。我很確定你在那個線程thread.stop得到異常。該功能不再受支持。有更好的方法來實現啓動畫面。在沒有線程的閃屏之後搜索。 –