Thursday 15 April 2010

android - crash after doInBackground return -


My AsyncTask crashed when doInBackground (try to return json object) in my case, it is called : Source attachment is not included source for asynctask.class file I do not know what is wrong in my code i Thanks!

My code:

  Public class CreateNetworkTask increases AsyncTask & lt; String, integer, JSONObject & gt; {Create network activity; // Private Progress DIOL Progadiyog; Public CreateNetworkTask (CreateNetwork Activity) {this.activity = activity; } @ Override protected JSONObject doInBackground (string ... parameter) {CommunicationModule comm = new CommunicationModule (); JSONObject jobjNewNetworkDetails = New JSONObject (); Try {JobjNewNetworkDetails.put ("name", activity.networkName); JobjNewNetworkDetails.put ("Description", activity.descrpNetwork); JobjNewNetworkDetails.put ("network_type", "personal"); // only for debug activity LocType = new string ("circle"); JobjNewNetworkDetails.put ("user_id", loginactive.muser .getId ()); JobjNewNetworkDetails.put ("location_type", activity.locType); If (activity.flag == 0) {//jobjNewNetworkDetails.put("center ", center); JobjNewNetworkDetails.put ("longitude", activity gender); JobjNewNetworkDetails.put ("Latitude", activity.Lat); JobjNewNetworkDetails.put ("radius", activity.radius); } Other {jobjNewNetworkDetails.put ("polygon", activity.networkLoc); }} Grip (JasonXExpress E) {// Todo Auto-Generated Catch Block e.printStackTrace (); } JSONObject jobj = comm.jsPackForCreateNetwork (activity.client, CreateNetwork.URL_STRING, JobsGenvanNetwork Details, Activity. Context); Return job; } @ Override Protected Zero on PreExecute () {// TODO Automatically generated method stub super.onPreExecute (); Activity.tvHttp.setText ("Loading data ..."); // progDialog = ProgressDialog.show (activity.context, "In progress", "Try to create your network"); } PostXextack on protected void (JasonObject works) {//progDialog.dismiss (); If (jobj == faucet) {activity.tvHttp.setText ("Error, try reloading!"); Return; } //progDialog.dismiss (); Try {activity.networkIdFromServer = jobj.getString ("network_id"). ToString (); } Grip (JasonAxpection E) {// Two-Auto Auto-Generated Cat Block E.Pintstaxtres (); }}   

}

My LogCat is:

  e / debug error (21124): the end of the input on the character 0 e / debug error (21124): org.json.JSONException: e / debug error character termination of input 0 (21124): org.json.JSONTokener.syntaxError (JSONTokener.java:450) e / debug error (21124.): org.json.JSONTokener.nextValue (JSONTokener.java:97) e / debug error on (21124): & LT on org.json.JSONObject; Init & gt; (JSONObject.java:154) E / debug error (21124): org.json.JSONObject & lt; Init & gt; (JSONObject.java:171) e / debug error (21124):. Org.example.communication.CommunicationModule.jsPackForCommentUpdate (CommunicationModule.java:437) on e / debug error (21124): org.example.communication.CreateNewUserTask.doInBackground (CreateNewUserTask.java39) e / debug error (21124): on org.example.communication.CreateNewUserTask.doInBackground (CreateNewUserTask.java:1) e / debug error on (21124): android.os.AsyncTask $ 2.call (AsyncTask.java:287) e / debug error (21124): java.util.concurrent.FutureTask.run on (FutureTask.java:2 34) e / debug error (21124): android.os.AsyncTask $ SerialExecutor at $ 1.run (AsyncTask.java:230) e / debug error ( 21124): java.util.concurrent.ThreadPoolExecutor.runWorker (on ThreadPoolExecutor.java: 1080) e / debug error (21124): java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:573) e / Debug error (21124): java.lang.Thread.run on (Thread.java: 856)    

OK, I did not find the solution, there was a delay between resone doInBackground and on PostExecute, a small delay occurs and after some compiler comes back to onPostExecute

No comments:

Post a Comment