Note that there are some explanatory texts on larger screens.

plurals
  1. POAsyncTask with readObject()
    primarykey
    data
    text
    <p>util.concurrent.FutureTask.finishCompletion when i try to open a file in internal storage i don't know how to handle that if you have some advices help me please </p> <p>My code:</p> <pre class="lang-java prettyprint-override"><code> protected String doInBackground(Hashtable&lt;String,String&gt;... params) { Hashtable ht=params[0]; String json=HelperHttp.getJSONResponseFromURL(url, ht); System.out.println(json); try { jObj = new JSONObject(json); ObjectOutput out = new ObjectOutputStream(new FileOutputStream(new File(getCacheDir(),"")+"cacheFile.srl")); out.writeObject(jObj.toString() ); out.close(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(json!=null) {try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File(new File(getCacheDir(),"")+"cacheFile.srl"))); JSONObject jsonObject; try { jsonObject = (JSONObject) in.readObject(); JSONArray articles = jsonObject.getJSONArray("posts"); for(int i = 0; i &lt; articles.length(); i++){ JSONObject c = articles.getJSONObject(i); // Storing each json item in variable AO=c.getJSONObject("post"); String fr_titre = AO.getString("fr_titre"); Log.d("hhhhhhhhhh", fr_titre); lista.add(fr_titre); } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } in.close(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ObjectStreamException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else{ return "Invalid Company Id"; } return "SUCCESS"; } </code></pre> <p>The stacktrace:</p> <pre><code>04-11 11:52:04.694: E/AndroidRuntime(1026): FATAL EXCEPTION: AsyncTask #1 04-11 11:52:04.694: E/AndroidRuntime(1026): java.lang.RuntimeException: An error occured while executing doInBackground() 04-11 11:52:04.694: E/AndroidRuntime(1026): at android.os.AsyncTask$3.done(AsyncTask.java:299) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.util.concurrent.FutureTask.run(FutureTask.java:239) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.lang.Thread.run(Thread.java:856) 04-11 11:52:04.694: E/AndroidRuntime(1026): Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.json.JSONObject 04-11 11:52:04.694: E/AndroidRuntime(1026): at com.cgi.activity.ActivityListNews$GetDeptAyncTask.doInBackground(ActivityListNews.java:81) 04-11 11:52:04.694: E/AndroidRuntime(1026): at com.cgi.activity.ActivityListNews$GetDeptAyncTask.doInBackground(ActivityListNews.java:1) 04-11 11:52:04.694: E/AndroidRuntime(1026): at android.os.AsyncTask$2.call(AsyncTask.java:287) 04-11 11:52:04.694: E/AndroidRuntime(1026): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 04-11 11:52:04.694: E/AndroidRuntime(1026): ... 3 more </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload