我有这个代码,只要它碰到Source.httpConn就会捕获它,它发送下面的异常来捕获。Android - 在捕获异常时在doinbackground期间显示警报对话框
try
{
JSONTokener sbTokener = new JSONTokener(Source.httpConn(infoUrlStr, Main.this).toString());
//array için hazırlandı
JSONArray jArray=new JSONArray(sbTokener);
//arraye eklendi
for(int i=0; i
.
.
.
}
在捕捉部分有我的警报对话方法。它通常工作得很好,但我怀疑我有这个问题,因为doInBackground。在显示下面的警报对话框之前,应用程序崩溃。所有的try-catch都在我的doInBackground方法中ASyncTask。
catch (Exception e) {
AlertDialogDisp(Main.this, noServ, noServLog);
}
我怎样才能让我的应用程序不会崩溃,只是显示此警告对话框,然后回到我的主要活动,因为它是。以下是我的提醒对话方法:
protected void AlertDialogDisp(Context dialogContext, String head, String log) {
new AlertDialog.Builder(dialogContext)
.setTitle(head)
.setMessage(log)
.setPositiveButton("okay", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// On Alert Dialog Button
dialog.dismiss();
}
})
.show();
}
+0
是你的aynsctask活动班的内部类吗? –
+0
@拉康丹丹是的。 –