【发布时间】:2010-10-10 18:18:28
【问题描述】:
当我的异步任务被执行时,它完全崩溃了应用程序 这是该类的代码。它位于我的主要活动课程内。 我是线程新手,很抱歉,如果我做了一些荒谬的事情,哈哈,我不完全理解。
编辑:
private class TeamSearchTask extends AsyncTask<String,Void,Void> {
CharSequence nfo;
String [] matches;
protected Void doInBackground(String... teamNumber)
{
//Team information ------------------------------------------------------------------------------------
//Array of team data
String [] data = APIconnection.getTeams(teamNumber[0], "");
//Display basic team info
nfo = ("\nFormal Team Name:\n" + data[1] +
"\n\nLocation:\n" + data [3] + ", " + data[4] + ", " + data[5] +
"\n\nRookie Year:\n" + data[6] +
"\n\nRobot Name:\n" + data[7] +
"\n\nWebsite:\n" + data[8] + "\n\n\n\n\n\n\n\n\n");
//Make match archive --------------------------------------------------------------------------------------
String [] events = APIconnection.getEventIdsByYear(year1);
String [] matches = new String [(events.length*11)];;
for (int i = 0; i<events.length; i++)
{
matches[(i*11) + i] = APIconnection.getMatches2(teamNumber[0], events[i] ,"","")[i];
}
return null;
}
protected void onProgressUpdate(Void...voids )
{}
protected void onPostExecute(Void result) {
info.setText(nfo);
matchArchive(matches);
}
}
【问题讨论】:
-
您显示的“堆栈”只是实际异常堆栈跟踪的一小部分。请向我们展示完整的崩溃,以便我们为您提供帮助。您至少应该查看引发的异常类型以了解可能导致它的原因(空指针?数组索引超出范围?等等)
-
@Romain Guy 我确实有一个 try catch 块打印错误(异常 e,然后它打印 e.toString())但它不起作用,它只是完全崩溃
-
日志中一定有什么。
-
Logcat 还是其他日志? (对不起,我不习惯 android dev-ing)
-
@Nick:我猜你正在运行 Eclipse。如果是这样,让 Eclipse 运行超过异常点,完整的堆栈跟踪将写入 LogCat,在您的 DDMS 透视图中可用。