Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8372873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:32:39+00:00 2026-06-09T14:32:39+00:00

I recently worked on an application which connects and parse data from a webserver

  • 0

I recently worked on an application which connects and parse data from a webserver into an android device, tested on froyo and gingerbread and works fine but crashes on ICS devices. As for the UI I used gingebread objects so I think it’s not the issue.

It works just fine on the first run even after connecting to facebook but errors on the part where it fetch and parse all of the JSON data gathered.

Here’s the logcat errors straight from the device:

E/AndroidRuntime(25620): FATAL EXCEPTION: Thread-9660
E/AndroidRuntime(25620): java.lang.UnsupportedOperationException
E/AndroidRuntime(25620):        at java.lang.Thread.stop(Thread.java:1076)
E/AndroidRuntime(25620):        at java.lang.Thread.stop(Thread.java:1063)
E/AndroidRuntime(25620):        at com.android.guestlist.SplashScreen$1.run(Spla
shScreen.java:89)
E/android.os.Debug( 2090): !@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/d
umpstate_app_error

E/Launcher(18546): Error finding setting, default accessibility to not found: ac
cessibility_enabled

E/log_tag (25620): Error in http connection android.os.NetworkOnMainThreadExcept
ion

E/log_tag (25620): Error converting result java.lang.NullPointerException

E/log_tag (25620): Error parsing data org.json.JSONException: End of input at ch
aracter 0 of

E/log_tag (25620): Error in http connection android.os.NetworkOnMainThreadExcept
ion

E/log_tag (25620): Error converting result java.lang.NullPointerException

E/log_tag (25620): Error in http connection android.os.NetworkOnMainThreadExcept
ion

E/log_tag (25620): Error parsing data org.json.JSONException: End of input at ch
aracter 0 of

And here’s my JSON parser since I think this is where the problem happens? And oh, the logs I created doesn’t even appear of the phone logs Well I can’t really say but here is the code:

public void getDataFromWeb(String a, String b){
        String result = "";

        Log.v(TAG, "Name Value Pair a " + a);
        Log.v(TAG, "Name Value Pair b " + b);

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

        nameValuePairs.add(new BasicNameValuePair("a_param",a));
        nameValuePairs.add(new BasicNameValuePair("b_param",b));

             try{
                     HttpClient httpclient = new DefaultHttpClient();
                     HttpPost httppost = new HttpPost("http://[mywebserviceshere].php");
                     httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                     HttpResponse response = httpclient.execute(httppost);
                     HttpEntity entity = response.getEntity();
                     is = entity.getContent();
                     Log.v(TAG, "connected");
             }catch(Exception e){
                     Log.v(TAG, "run failed");

                     Log.e("log_tag", "Error in http connection "+e.toString());
             }

             try{
                     BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
                     sb = new StringBuilder();
                     String line = "0";

                     while ((line = reader.readLine()) != null) {
                             sb.append(line + "\n");
                     }
                     is.close();
                     result=sb.toString(); 
                     Log.v(TAG, "buffered read");
             }catch(Exception e){
                 Log.v(TAG, "buffered error");
                     Log.e("log_tag", "Error converting result "+e.toString());
             }

             try{
                 Log.v(TAG, result);

                     JSONArray jArray = new JSONArray(result);
                     JSONObject json_data=null;

                     for(int i=0;i<jArray.length();i++){
                         Log.v(TAG, "loop start");

                             json_data = jArray.getJSONObject(i);
                             w.add(json_data.getString("w_data"));
                             x.add(json_data.getString("x_data"));
                             y.add(json_data.getString("y_data"));
                             z.add(json_data.getString("y_data"));
                             Log.v(TAG, "list added");
                     }

             }catch(JSONException e){
                 w.add("0");
                 x.add("No Data");
                 y.add("No Data");
                 z.add("No Data");
                 Log.v(TAG, "rest failed");
                     Log.e("log_tag", "Error parsing data "+e.toString());
             }


    }

And finally here’s exactly what it looks like in AVD:

enter image description here

Is this an issue on ICS or I have to revise some of my codes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:32:40+00:00Added an answer on June 9, 2026 at 2:32 pm

    You’ve got a NetworkOnMainThreadException and that is generally a sign of poor code, and it’ll result in a bad user experience because the application locks up whenever it’s running some sort of network activity. Yes, it (unfortunately) works on pre-Honeycomb devices, but it’s not what anyone should be going for.

    To solve your problem, I’d highly recommend you use a single AsyncTask and do all your HTTP calls in the doInBackground() method. Once they’re completed, the onPostExecute() method will be called automatically, so you can update the GUI. Quite simple.

    Take a look at the documentation for AsyncTask and understand it before doing anything else. I’m sure this will work perfectly for your application: http://developer.android.com/reference/android/os/AsyncTask.html

    So no – it’s not a problem with Ice Cream Sandwich. It simply won’t allow you to make network requests on the main thread because it can block everything else.

    (this is pretty similar to another question I answered a few days ago, so part of the answer is copied from there: https://stackoverflow.com/a/11897381/762442)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently worked with Hyper Terminal on windows 7 in which i access SMS
I recently developed a Visual C++ console application which uses inline SSE2 instructions. It
I have a C# service application which interacts with a database. It was recently
I recently started compiling my iPhone application against the 3.0 OS. The app worked
Recently, I ran into a problem with my application: the size of the JSON
I have a web application which displays pdf's in an IFrame. I recently made
We have a legacy VB6 application which has worked just fine on Windows XP
I recently worked through Steve Sanderson's Pro ASP.NET MVC Framework and ran into an
I've been working on a small application recently which consists of an index page
I recently worked on a live wallpaper application. In that i found out my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.