1

I've to try for convert from string to json array. But still following error

.addBodyParameter("checkbox1", String.valueOf(s.getCheckbox1()))

I use that code for convert from string to jsonarray
This is my full code,

public void add(Spacecraft s, final View...inputViews)
{
    if(s==null)
    {
        Toast.makeText(c, "No Data To Save", Toast.LENGTH_SHORT).show();
    }
    else
    {
        AndroidNetworking.post(DATA_INSERT_URL)
                .addBodyParameter("action","save")
                .addBodyParameter("checkbox1", String.valueOf(s.getCheckbox1()))
                .setTag("TAG_ADD")
                .build()
                .getAsJSONArray(new JSONArrayRequestListener() {
                    @Override
                    public void onResponse(JSONArray response) {

                        if(response != null)
                            try
                            {
                                String responseString = response.get(0).toString();
                                Toast.makeText(c, "PHP SERVER RESPONSE : " + responseString, Toast.LENGTH_SHORT).show();


                            } catch (JSONException e) {
                                e.printStackTrace();
                                Toast.makeText(c, "GOOD RESPONSE BUT JAVA CAN'T PARSE JSON IT RECEIVED : "+e.getMessage(), Toast.LENGTH_SHORT).show();
                            }

                    }

                    @Override
                    public void onError(ANError anError) {
                        Toast.makeText(c, "UNSUCCESSFUL :  ERROR IS : "+anError.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });
    }
}

1 Answer 1

1

String.valueOf(s.getCheckbox1()) has no sense to me. Maybe you wanted to check state with s.getCheckbox1().isChecked()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.