我有活动A和B.他们都有AsyncTasks连接到网络并获取一些JSON。我得到一个我无法复制的错误,但我不确定我做错了什么。当我从活动B按下后退按钮到A到主屏幕时,我收到错误。
protected Void doInBackground(Void... params) {
synchronized (this) {
if (img_flag == 1) {
System.out.println("entered into doinback1");
UploadImage();
System.out.println("entered into doinback2");
}
if (offlineast_flag == 0) {
System.out.println("entered into doinback3");
UpdateAsset_webService();
System.out.println("entered into doinback4");
ServiceRequest _autoupdate = new ServiceRequest();
_autoupdate.cat_sync(Update_asset.this, _companyId, _usrid,
access_id, profile_id, catid_db);
System.out.println("entered into doinback5");
}
if (img_flag == 2) {
System.out.println("entered into doinback6");
UploadImageOffline();
} else {
System.out.println("entered into doinback7");
loading_dialog.dismiss();
System.out.println("entered into doinback8");
}
}
return null;
}
// Update the progress
protected void onProgressUpdate(Integer... values) {
}
// after executing the code in the thread
protected void onPostExecute(Void result) {
onback();
loading_dialog.dismiss();
img_flag = 0;
Toast.makeText(getApplicationContext(),
"Your asset updated successfully.", Toast.LENGTH_LONG)
.show();
}
这是我的Logcat:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.Futuenter code herereTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NullPointerException
at com.kodology.assetbin.Update_asset.UpdateAsset_webService(Update_asset.java:1733)
at com.kodology.assetbin.Update_asset$LoadViewTask.doInBackground(Update_asset.java:2239)
at com.kodology.assetbin.Update_asset$LoadViewTask.doInBackground(Update_asset.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more