mercredi 11 juillet 2018

my android api does not show me anything and without error?

I'm working on a web service application, I display the data in a listview At the beginning everything works but when I changed my api nothing is displayed and no error appears , I did not find the problem please !! how can I display my data !!

it's the part of the code !!

 private class GetHttpResponse extends AsyncTask<String, Void, 
      ArrayList<subjects>>
  {
    public Context context;
    String ResultHolder;
    public GetHttpResponse(Context context)
    {
        this.context = context;
    }
    @Override
    protected void onPreExecute()
    {
        super.onPreExecute();
    }
     @Override
    protected ArrayList<subjects> doInBackground(String... arg0)
    {
        HttpServicesClass httpServiceObject = new HttpServicesClass(arg0[0]);
        ArrayList<subjects> subjectsList = new ArrayList<subjects>();
        try
        {
            httpServiceObject.ExecutePostRequest();

            if(httpServiceObject.getResponseCode() == 200)
            {
                ResultHolder = httpServiceObject.getResponse();

               if(ResultHolder != null)
                {
                    JSONArray jsonArray = null;

                    try {
                        jsonArray = new JSONArray(ResultHolder);

                        JSONObject jsonObject;

                        subjects subjects;

                        for(int i=0; i<jsonArray.length(); i++)
                        {
                            subjects = new subjects();
                       jsonObject = jsonArray.getJSONObject(i);
                  if(valueInteger == jsonObject.getInt("tache_id") )
                            {
                           //   subjects.nom=jsonObject.getString("nom");
                                subjects.SubjectName = 
 jsonObject.getDouble("tarif");
                                subjects.technicien_id = 
 jsonObject.getString("technicien_id");
                                subjectsList.add(subjects);
}}}
                    catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
           }}}}
        catch (Exception e)
        {
            // TODO Auto-generated catch block
            Log.e("Tech", "exception", e);
        }
        return subjectsList;
    }

and this is my json

[
{
    "tache_id": "2",
    "technicien_id": "2",
    "tarif": "100"
},
{
    "tache_id": "3",
    "technicien_id": "3",
    "tarif": "200"
}]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire