我目前使用扩展AsyncTask
的类将一些数据发布到php webservice。单独线程上的同步HttpPost
现在我需要进行同步调用,因为我想显示数据发送后我的应用程序崩溃的默认异常弹出窗口(previousHandler.uncaughtException(t, e)
)。
我可以只对AsyncTask
禁用异步功能,或者你有任何其他建议
这里是我当前的代码,在此先感谢:
public void uncaughtException(Thread t, Throwable e) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
String stacktrace = result.toString();
printWriter.close();
String deviceUuid = Utilities.DeviceUuid(ctx, cr);
String bluetoothName = Utilities.LocalBluetoothName();
AsyncTasks.ErrorLogTask logTask = new AsyncTasks.ErrorLogTask(e, bluetoothName, deviceUuid, stacktrace);
logTask.execute();
//task wont be complete before this code below runs since its async.
previousHandler.uncaughtException(t, e);
}