Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have created a code to parse the data(job listings) from my website and should make it displayed in Android app, i have used JSON parser to do this task, So installed JSON api in the website, project is bug free, but when i run i'm not getting the output... i think i have gone wrong in defining the JSONobject. Here's my code

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.httpex);
    httpStuff = (TextView) findViewById(R.id.tvHttp);
    client = new DefaultHttpClient();
    new Read().execute("posts");
    }
    public JSONObject lastTweet(String string) throws ClientProtocolException, IOException, JSONException {
        StringBuilder url = new StringBuilder(URL);
        url.append(string);
        HttpGet get = new HttpGet (url.toString());
        HttpResponse r = client.execute(get);
        int status = r.getStatusLine().getStatusCode();
        if (status==200){
            HttpEntity e=r.getEntity();
            String data = EntityUtils.toString(e);
            JSONArray Categories = new JSONArray(data);
            JSONObject Featured = Categories.getJSONObject(1);
            return Featured;
        }
        else
        {
            Toast.makeText(HttpExample.this, "error", Toast.LENGTH_LONG);
            return null;
        }
    }
    public class Read extends AsyncTask<String, Integer, String>{

        @Override
        protected String doInBackground(String... params) {
            // TODO Auto-generated method stub
            try{
            json = lastTweet("mybringback");
            return json.getString(params[0]);
            }
            catch (ClientProtocolException e) {
                e.printStackTrace();
            }
            catch (IOException e){
                e.printStackTrace();
            }
            catch (JSONException e){
                e.printStackTrace();
            }

            return null;
        }

This code was done by following some tutorial where that was to parse the twitter content, so i edited the url and JSONobject by mine. so please help me to correct the errors.

share|improve this question
Programming Android apps is off topic here. You might have more luck on Stack Overflow. Before you ask there make sure to collect some useful debug information. – toscho Nov 22 '12 at 6:34
before defining JSONobject class, i'm getting the xml response from my website but after installing json api plugin in the website, after that no output is coming, i searched for the related topic but its of no use... – Divya Jehova Nov 22 '12 at 6:41
help me to correct the errors is not a question: there are no errors in your post. – toscho Nov 22 '12 at 6:49

closed as off topic by toscho Nov 22 '12 at 6:34

Questions on WordPress Answers are expected to relate to WordPress within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.