1
현재 JSON 문자열을 구문 분석하는 비동기 작업을하고 있습니다. 문자열 구문 분석 및 doInBackground()에서 작업은 나에게이 오류주고) postExecute (로 이동되면 : 그것은 완벽하게 이전에 작업 한비동기 작업 null 오류
06-17 20:19:53.612: E/AndroidRuntime(591): FATAL EXCEPTION: main
06-17 20:19:53.612: E/AndroidRuntime(591): java.lang.NumberFormatException: unable to parse 'null' as integer
06-17 20:19:53.612: E/AndroidRuntime(591): at java.lang.Integer.parseInt(Integer.java:356)
06-17 20:19:53.612: E/AndroidRuntime(591): at java.lang.Integer.parseInt(Integer.java:332)
06-17 20:19:53.612: E/AndroidRuntime(591): at stefan.testservice.ParkingActivity$DownloadTask.onPostExecute(ParkingActivity.java:258)
06-17 20:19:53.612: E/AndroidRuntime(591): at android.os.AsyncTask.finish(AsyncTask.java:417)
06-17 20:19:53.612: E/AndroidRuntime(591): at android.os.AsyncTask.access$300(AsyncTask.java:127)
06-17 20:19:53.612: E/AndroidRuntime(591): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
06-17 20:19:53.612: E/AndroidRuntime(591): at android.os.Handler.dispatchMessage(Handler.java:99)
06-17 20:19:53.612: E/AndroidRuntime(591): at android.os.Looper.loop(Looper.java:123)
06-17 20:19:53.612: E/AndroidRuntime(591): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-17 20:19:53.612: E/AndroidRuntime(591): at java.lang.reflect.Method.invokeNative(Native Method)
06-17 20:19:53.612: E/AndroidRuntime(591): at java.lang.reflect.Method.invoke(Method.java:507)
06-17 20:19:53.612: E/AndroidRuntime(591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-17 20:19:53.612: E/AndroidRuntime(591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-17 20:19:53.612: E/AndroidRuntime(591): at dalvik.system.NativeStart.main(Native Method)
, 단지 그것의 갑자기이 일부에 문제가있는 것을 비동기 작업의 끝에서 'return null'문. 솔루션을 찾을 수없는 것 같습니다. 미리 감사드립니다.
내 코드 :
private class DownloadTask extends AsyncTask<String, Void, Object> {
@Override
protected Object doInBackground(String... args) {
Log.i("MyApp", "Background thread starting");
Global.url = "http://10.0.2.2:8000/CarServiceScheduling1/resources/json/product/getpark?degree="+degreeStatus+"&year="+yearStatus+"&distance="+distance+"&devid="+Global.android_id;
try{
statusCode = cg.connection();
}catch (Exception e) {
test_connection = true;
}
if(test_connection == false){
try {
output = cg.stringconverter(Global.data);
cg.parseGson(output);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}
protected void onPostExecute(Object result) {
if (ParkingActivity.this.progressDialog != null) {
ParkingActivity.this.progressDialog.dismiss();
if(CheckboxPreference == true && Integer.parseInt(Global.preference1) == 0 && Integer.parseInt(Global.preference2) == 0 && (Global.status.equalsIgnoreCase("No Slots available") || Global.status.equalsIgnoreCase("No"))){
Intent searchSubActivity = new Intent(getBaseContext(),
Nospotsactivity.class);
startActivity(searchSubActivity);
}
else if (CheckboxPreference == true && (Integer.parseInt(Global.preference1) != 0 || Integer.parseInt(Global.preference2) != 0)){
Intent searchSubActivity = new Intent(getBaseContext(),
Spotsfoundactivity.class);
startActivity(searchSubActivity);
}
else if(CheckboxPreference == false && (Integer.parseInt(Global.preference1) != 0 || Integer.parseInt(Global.preference2) != 0)){
Intent searchSubActivity = new Intent(getBaseContext(),
Spotsfoundactivity.class);
startActivity(searchSubActivity);
}
if(Integer.parseInt(Global.preference1) == 0 && Integer.parseInt(Global.preference2) == 0){
if(Global.status.equalsIgnoreCase("Hardly Likely")){
Intent searchSubActivity = new Intent(getBaseContext(),
Unlikelyactivity.class);
startActivity(searchSubActivity);
}
else if(Global.status.equalsIgnoreCase("Likely")){
Intent searchSubActivity = new Intent(getBaseContext(),
Likelyactivity.class);
startActivity(searchSubActivity);
}
}
}
}
}
}
}
'구문 분석 할 수 없습니다'null '정수로'그래서 처음으로 확인 문자열은 null로 또는 정수로 구문 분석하기 전에 –
친절하게 내가 무슨 말을하는지 정확히 이해하지 못해서 제발 수 있습니까 – progdoc
그는 로그의 관련 부분은 java.lang.NumberFormatException : 'null'을 정수로 구문 분석 할 수 없습니다. 너는 무언가에 null을 전달하고있다. 전달하기 전에 null을 확인하십시오. – keyser