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

  • Home
  • SEARCH
  • 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 7056823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:54:46+00:00 2026-05-28T03:54:46+00:00

I am currently developing an android app for 1.6 that parses a json file

  • 0

I am currently developing an android app for 1.6 that parses a json file received from a server and then displays the results in a listview. So far all of my beta testers have had no issues except for one who owns an HTC G2 running on Android 2.2. He said that he does not see anything on his listview, making me think that there was some problem with the json retrieving or parsing. He also said that he did not have any internet issues while running the app. Even my “refresh” option does not solve his problem. I am wondering if there is anything particularly different about the G2 that would cause this. Here is the code where I deal with the JSON.

First I use an OAuth client to get the file

OAuthMessage request = accessor.newRequestMessage(method, url, parameters); 
response = client.invoke(request, OAuthClient.ParameterStyle.BODY); 
if (("application/json; charset=utf-8").equals(response.getBodyType())) {
                return response.readBodyAsString();

I also display a toast if there was an issue with the json fetching

        if (result instanceof Exception) {
        // If failed during refreshing vouchers, show message to user
        if (USER_REFRESH.equals(flag) || SYSTEM_REFRESH.equals(flag)) {
            ((ListVouchers)context).getProgressDialog().cancel();
            Toast.makeText(context, "Could not load. Try again later.", Toast.LENGTH_LONG).show();
        }

Then I store information from the JSON into a database:

    JSONArray jArray = new JSONArray(params[0]);
            int jarrayLength = jArray.length();
            //Create a set of the ids in the json
            for (int i  = 0; i < jarrayLength; i++) {
                JSONObject jsonObj = jArray.getJSONObject(i);
            JSONObject categoryObj = jsonObj.getJSONObject("category");
                    values.put("categoryName", categoryObj.getString("name"));
                    values.put("categoryId", categoryObj.getString("id")); }
                        contentResolver.insert(CONTENT_URI, values);

Does anyone have any idea why a G2 in particular would not do this correctly? The user is reporting no crashes, just that he sees my empty view where there is supposed to be information from the json. The only issue I think would cause this is a lack of space but I don’t think the user’s phone can’t store a few kb of json text. I have done an admin login of his account and it works fine on the phones I use for testing.

Edit:

I have asked the user for a logcat and it seems the problem stems from this error:

org.json.JSONException: Value other of type java.lang.String cannot be converted to JSONArray

which happens on this line, where params[0] is the result from the server:

JSONArray jArray = new JSONArray(params[0]);

Could this have to do with certain phones handling text files differently? It seems that the result is not being detected as a json file

  • 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-05-28T03:54:47+00:00Added an answer on May 28, 2026 at 3:54 am

    I found the problem. it turns out the httpclient on the person’s G2 was giving a content-type without a space in application/json; charset=UTF-8. I fixed this issue by checking for “application/json” instead of of ‘application/json; charset=UTF-8’.

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

Sidebar

Related Questions

A new question about android and services. Currently I'm developing a App that should
I'm currently developing an android app that will regularly stop to watch streamed video.
I am developing an app for android mobiles that communicates with a json/rest web
I am currently developing an Android app that is supposed to inform the user
I am currently developing an Android app that is using a remote MySQL database
I have an Android app that I am currently developing. I have created icons
I am developing a playlist app for Android which has a ListView that contains
I'm currently developing an Android application that fetches images using http requests. It would
I'm currently developing my first android app, and my first game. I've been developing
I'm developing a Android desktop app, and I would like that when it first

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.