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 8361007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:36:18+00:00 2026-06-09T11:36:18+00:00

I have got a code from a tutorial How to parse JSON data into

  • 0

I have got a code from a tutorial How to parse JSON data into a Custom Listview

Here is the code from the tutorial with a couple of modifications:

public class TwitterParseHandler extends Activity {
ArrayList<TwitterFeed> arrayOfWebData = new ArrayList<TwitterFeed>();

class TwitterFeed {
    public String text;
    public String created_at;
}

FancyAdapter aa=null;

static ArrayList<String> resultRow;

public void onCreate(Bundle savedInstanceState) {
    try
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_twitter_parse_handler);
        String result = "";

        try
        {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=3FMNu&count=20&exclude_replies=True");
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            InputStream webs = entity.getContent();

            try
            {
                BufferedReader reader = new BufferedReader(new InputStreamReader(webs, "iso-8859-1"),8);
                StringBuilder sb = new StringBuilder();
                String line = null;
                while ((line = reader.readLine()) != null) {
                    sb.append(line + "/n");
                }

                webs.close();
                result=sb.toString();
            }catch(Exception e){
                Log.e("log_tag", "Error in converting result "+e.toString());
            }
        }catch(Exception e){
            Log.e("log_tag", "Error in http connection "+e.toString());
        }

        try
        {
            JSONArray jArray = new JSONArray(result);
            for (int i=0;i<jArray.length();i++)
            {
                JSONObject json_data = jArray.getJSONObject(i);
                TwitterFeed resultRow = new TwitterFeed();
                resultRow.text = json_data.getString("text");
                resultRow.created_at = json_data.getString("created_at");

                arrayOfWebData.add(resultRow);
            }
        }catch(JSONException e){
            Log.e("log_tag", "Error in parsing data "+e.toString());
        }

        ListView myListView = (ListView)findViewById(R.id.list);

        aa=new FancyAdapter();

        myListView.setAdapter(aa);
    }
    catch(Exception e){
        Log.e("ERROR", "ERROR IN CODE: "+e.toString());
        e.printStackTrace();
    }
}

class FancyAdapter extends ArrayAdapter<TwitterFeed> {
    FancyAdapter() {
        super(TwitterParseHandler.this, android.R.layout.simple_list_item_1, arrayOfWebData);
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView==null) {
            LayoutInflater inflater=getLayoutInflater();
            convertView=inflater.inflate(R.layout.twitterlist, null);

            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        else
        {
            holder=(ViewHolder)convertView.getTag();
        }
        holder.populateFrom(arrayOfWebData.get(position));

        return(convertView);
    }
}

class ViewHolder {
    public TextView name=null;
    public TextView birthday=null;

    ViewHolder(View row) {
        name=(TextView)row.findViewById(R.id.TwitterText);
        birthday=(TextView)row.findViewById(R.id.TwitterDatum);
    }

    void populateFrom(TwitterFeed r) {
        name.setText(r.text);
        birthday.setText(r.created_at);
    }
}
}

I have replaced the JSON from the tutorial (that was working fine) with my twitterfeed: https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=3FMNu&count=20&exclude_replies=True

and changed the attributes from name and birthday to text and created_at, now when I debug it I get the following error:

08-04 12:36:40.539: E/log_tag(4599): Error in parsing data org.json.JSON
Exception: Value 
{ "error": "This method requires a GET.",
  "request":"\/1\/statuses\/user_timeline.json?include_entities=true&include_rts=true&screen_name=3FMNu&count=20&exclude_replies=True"
} of type org.json.JSONObject cannot be converted to JSONArray

Why does this happen and how do I fix it?

  • 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-09T11:36:20+00:00Added an answer on June 9, 2026 at 11:36 am

    Try:

    HttpGet httpGet = new HttpGet(https://api.twitter.com/1/statuses/user_timeline.json);
    

    with parameters:

    List<NameValuePair> params = new LinkedList<NameValuePair>();
    params.add(new BasicNameValuePair("include_entities", true));
    ...
    

    Try also How to add parameters to a HTTP GET request in Android?

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

Sidebar

Related Questions

I have a small assembly bootloader that I got from this Tutorial . The
I got this code from this site: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx But I'm just a beginner so
Ive got this code from an ebook tutorial on embedding MPMoviePlayerController from a VIEW
I have taken code from GeoTweets tutorial from Sencha Touch learning center and it's
I'm doing tutorial from website http://www.plsqltutorial.com/plsql-procedure/ . I have run the code on apex:
I have picked up this code from a tutorial and have edited it make
I have got code like this var challegneListener; $(document).ready(function(){ var challegneListener = setInterval(challengeListenerBot(),5000); });
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have got this code: $subject=<<<EOD <object height=400 width=500><param name=allowfullscreen value=false> <param name=AllowScriptAccess value=always>
I have got this code for detection of mobile device. <?xml version=1.0 encoding=UTF-8?> <configuration>

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.