Skip to main content
adicionou 642 caracteres ao conteúdo
Fonte Link
Leonardo Dias
  • 4,3mil
  • 10
  • 26

Tenho um codigo que deveria fazer um "Post" via json ,mas o edittext não está convertendo para String,e não da nenhum erro no logcat ..Alguem tem ideia do erro?Deve ser algo idiota peço desculpas,mas sou novata em android.

public class PostTeste extends AppCompatActivityTenho um codigo que deveria fazer um "Post" via json {

private Button btnfincad;
private EditText name,nick,email,password,number,sexo,tpativo;

private String mName,mNick,mEmail,mPassword,mNumber,mSexomas o edittext não está convertendo para String,mTpativo;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cadastro);

    btnfincad = (Button) findViewById(R.id.btnfincad);
    nick = (EditText) findViewById(R.id.etnick);
    email = (EditText)findViewById(R.id.Cemail);
    password = (EditText)findViewById(R.id.Cpassword);
    number = (EditText)findViewById(R.id.etnumcel);
    sexo = (EditText)findViewById(R.id.sexo);
    tpativo = (EditText)findViewById(R.id.tpativo);


    btnfincad.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            btnfincad.setOnClickListener(new View.OnClickListener()
            {
                public void onClick(View v) {
                    new onbuttonclickHttpPost().execute();
                    name = (EditText) findViewById(R.id.etname);
                    String mName = name.getText().toString();
                    String mNick = nick.getText().toString();
                    String mEmail = email.getText().toString();
                    String mPassword = password.getText().toString();
                    String mNumber = number.getText().toString();
                    String mSexo = sexo.getText().toString();
                    String mTpativo = tpativo.getText().toString();


                }

                
            });
        }
    });
}

        public class onbuttonclickHttpPost  extends AsyncTask<String, Void, String> {


            protected void onPreExecute() {
            }


            protected String doInBackground(String... arg0) {


                try {


                    URL url = new URL("Api url");

                    JSONObject postDataParams = new JSONObject();

/* HttpURLConnection httpCon =e não da nenhum erro no logcat (HttpURLConnection) url.openConnection();.Alguem tem ideia do erro?Deve ser algo idiota peço desculpas,mas sou novata em android.

            httpCon.setRequestProperty("Content-type", "application/json");
            httpCon.setRequestProperty("Accept", "application/json");
            httpCon.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
            httpCon.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJ1c2VyX2lkIjoxNCwiZW1haWwiOiJ0aGlhZ28uY2FtYXJnb0Bldm9sdXRpb25pdC5jb20uYnIiLCJmb3JldmVyIjpmYWxzZSwiaXNzIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIwN1wvYXBpXC92Mlwvc3lzdGVtXC9hZG1pblwvc2Vzc2lvbiIsImlhdCI6MTQ5NDE4NjA2MCwiZXhwIjoxNDk0MTg5NjYwLCJuYmYiOjE0OTQxODYwNjAsImp0aSI6ImM5N2VkMzY4MDU0MWQ5ZDI3OGJkZjAwNWYwMmMwYmY0In0.2j06THHfdJiBdwWOP1Dpkqs1Un2tSeVWa0NxVBpNxBo");
            httpCon.setRequestProperty("Authorization", "Basic  dGhpYWdvLmNhbWFyZ29AZXZvbHV0aW9uaXQuY29tLmJyOmluaWNpYWwyMDE3");
            httpCon.setRequestMethod("POST");
            httpCon.setReadTimeout(15000 *//* milliseconds *//*);
            httpCon.setConnectTimeout(15000 *//* milliseconds *//*);
            httpCon.setDoInput(true);
       public class PostTeste extends AppCompatActivity httpCon.setDoOutput(true);*/{


                    HttpURLConnection conn =private (HttpURLConnection)Button url.openConnection();btnfincad;
                  private EditText conn.setRequestProperty("Content-type"name, "application/json");
                    conn.setRequestProperty("Accept"nick, "application/json");
                    conn.setRequestProperty("X-DreamFactory-Api-Key"email, "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                    conn.setRequestProperty("X-DreamFactory-Session-Token"password, "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.fb69q5ByrWAMhanFWMpye78KN7OxgYC0IGsdoGgUYps");
                    conn.setRequestProperty("Authorization"number, "Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                    //conn.setRequestProperty("-d"sexo, "{}");
                    conn.setRequestMethod("POST");
                    conn.setReadTimeout(15000 /* milliseconds */);
                    conn.setConnectTimeout(15000 /* milliseconds */);
                    conn.setDoInput(true);tpativo;
                  private String conn.setDoOutput(true);mName,mNick,mEmail,mPassword,mNumber,mSexo,mTpativo;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cadastro);

        btnfincad = (Button) findViewById(R.id.btnfincad);
        nick = (EditText) findViewById(R.id.etnick);
        email = (EditText)findViewById(R.id.Cemail);
        password = (EditText)findViewById(R.id.Cpassword);
        number = (EditText)findViewById(R.id.etnumcel);
        sexo = (EditText)findViewById(R.id.sexo);
        tpativo = (EditText)findViewById(R.id.tpativo);

                    postDataParams.put("email", "mName");
                    postDataParams.put("password", "mNick");
                    postDataParams.put("dt_nascimento", "mData");
                    postDataParams.put("nu_cellphone", "mNumber");
                    postDataParams.put("password", "mPassword");
                    postDataParams.put("sexo", "mSexo");
                    postDataParams.put("tp_ativo", "mTpativo");

        btnfincad.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                    Log.e("resource", postDataParams.toString());

                btnfincad.setOnClickListener(new View.OnClickListener()
                {
                    public void onClick(View v) {
                        new onbuttonclickHttpPost().execute();
                        name = (EditText) findViewById(R.id.etname);
                        String mName = name.getText().toString();
                        String mNick = nick.getText().toString();
                        String mEmail = email.getText().toString();
                        String mPassword = password.getText().toString();
                        String mNumber = number.getText().toString();
                        String mSexo = sexo.getText().toString();
                        String mTpativo = tpativo.getText().toString();


                    }

                    //postDataParams.put("password", 
 "password"               });
            }
        });
    }

                    JSONObject resource = new JSONObject();
                    JSONArray array = new JSONArray();
                    array.put(postDataParams);
              public class onbuttonclickHttpPost  extends AsyncTask<String, resource.put("resource"Void, array);String> {

                    System.out.println(resource.toString());

                protected void onPreExecute() {
                }

                    conn.connect();

                    OutputStream os = conn.getOutputStream();
                    BufferedWriter writer = new BufferedWriter(
                           protected newString OutputStreamWriterdoInBackground(os, "UTF-8"));
                    //writerString.write(getPostDataString(postDataParams));
                    writer.write(resource.toString() arg0); {

                    writer.flush();
                    writer.close();
                    os.close();

                    int responseCode =try conn.getResponseCode();{

                    if (responseCode == HttpsURLConnection.HTTP_OK) {

                        BufferedReaderURL inurl = new BufferedReader(new InputStreamReader(conn.getInputStreamURL()));
                        StringBuffer sb = new"Api StringBuffer(""url");
                        String line = "";

                        whileJSONObject ((linepostDataParams = in.readLinenew JSONObject());
/*
 !               HttpURLConnection httpCon = null(HttpURLConnection) {url.openConnection();

                httpCon.setRequestProperty("Content-type", "application/json");
            sb    httpCon.appendsetRequestProperty(line"Accept", "application/json");
                httpCon.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                break;httpCon.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJ1c2VyX2lkIjoxNCwiZW1haWwiOiJ0aGlhZ28uY2FtYXJnb0Bldm9sdXRpb25pdC5jb20uYnIiLCJmb3JldmVyIjpmYWxzZSwiaXNzIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIwN1wvYXBpXC92Mlwvc3lzdGVtXC9hZG1pblwvc2Vzc2lvbiIsImlhdCI6MTQ5NDE4NjA2MCwiZXhwIjoxNDk0MTg5NjYwLCJuYmYiOjE0OTQxODYwNjAsImp0aSI6ImM5N2VkMzY4MDU0MWQ5ZDI3OGJkZjAwNWYwMmMwYmY0In0.2j06THHfdJiBdwWOP1Dpkqs1Un2tSeVWa0NxVBpNxBo");
                httpCon.setRequestProperty("Authorization", "Basic  dGhpYWdvLmNhbWFyZ29AZXZvbHV0aW9uaXQuY29tLmJyOmluaWNpYWwyMDE3");
     }           httpCon.setRequestMethod("POST");
                httpCon.setReadTimeout(15000 *//* milliseconds *//*);
                httpCon.setConnectTimeout(15000 *//* milliseconds *//*);
                httpCon.setDoInput(true);
                httpCon.setDoOutput(true);*/


                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                        conn.setRequestProperty("Content-type", "application/json");
                        conn.setRequestProperty("Accept", "application/json");
                        conn.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                        conn.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.fb69q5ByrWAMhanFWMpye78KN7OxgYC0IGsdoGgUYps");
                        conn.setRequestProperty("Authorization", "Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                        //conn.setRequestProperty("-d", "{}");
                        conn.setRequestMethod("POST");
                        conn.setReadTimeout(15000 /* milliseconds */);
                        conn.setConnectTimeout(15000 /* milliseconds */);
                        conn.setDoInput(true);
                        conn.setDoOutput(true);



                        postDataParams.put("email", "mName");
                        postDataParams.put("password", "mNick");
                        postDataParams.put("dt_nascimento", "mData");
                        postDataParams.put("nu_cellphone", "mNumber");
                        postDataParams.put("password", "mPassword");
                        postDataParams.put("sexo", "mSexo");
                        postDataParams.put("tp_ativo", "mTpativo");


                        Log.e("resource", postDataParams.toString());




                        //postDataParams.put("password", "password");

                        JSONObject resource = new JSONObject();
                        JSONArray array = new JSONArray();
                        array.put(postDataParams);
                        resource.put("resource", array);

                        System.out.println(resource.toString());


                        conn.connect();

                        OutputStream os = conn.getOutputStream();
                        BufferedWriter writer = new BufferedWriter(
                                new OutputStreamWriter(os, "UTF-8"));
                        //writer.write(getPostDataString(postDataParams));
                        writer.write(resource.toString());

                        writer.flush();
                        writer.close();
                        os.close();

                        int responseCode = conn.getResponseCode();

                        if (responseCode == HttpsURLConnection.HTTP_OK) {

                            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                            StringBuffer sb = new StringBuffer("");
                            String line = "";

                            while ((line = in.readLine()) != null) {

                                sb.append(line);
                                break;
                            }

                            in.close();
                            return sb.toString();
                        } else {
                            return new String("false : " + responseCode);
                        }
                    } catch (Exception e) {
                        return new String("Exception: " + e.getMessage());
                    }
                } catch (Exception e) {
                    return new String("Exception: " + e.getMessage());
                }
            }

                @Override
                protected void onPostExecute(String result) {
                    Toast.makeText(getApplicationContext(), result,
                            Toast.LENGTH_LONG).show();

                }
            }
        }

        }

Tenho um codigo que deveria fazer um "Post" via json ,mas o edittext não está convertendo para String,e não da nenhum erro no logcat ..Alguem tem ideia do erro?Deve ser algo idiota peço desculpas,mas sou novata em android.

public class PostTeste extends AppCompatActivity {

private Button btnfincad;
private EditText name,nick,email,password,number,sexo,tpativo;

private String mName,mNick,mEmail,mPassword,mNumber,mSexo,mTpativo;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cadastro);

    btnfincad = (Button) findViewById(R.id.btnfincad);
    nick = (EditText) findViewById(R.id.etnick);
    email = (EditText)findViewById(R.id.Cemail);
    password = (EditText)findViewById(R.id.Cpassword);
    number = (EditText)findViewById(R.id.etnumcel);
    sexo = (EditText)findViewById(R.id.sexo);
    tpativo = (EditText)findViewById(R.id.tpativo);


    btnfincad.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            btnfincad.setOnClickListener(new View.OnClickListener()
            {
                public void onClick(View v) {
                    new onbuttonclickHttpPost().execute();
                    name = (EditText) findViewById(R.id.etname);
                    String mName = name.getText().toString();
                    String mNick = nick.getText().toString();
                    String mEmail = email.getText().toString();
                    String mPassword = password.getText().toString();
                    String mNumber = number.getText().toString();
                    String mSexo = sexo.getText().toString();
                    String mTpativo = tpativo.getText().toString();


                }

                
            });
        }
    });
}

        public class onbuttonclickHttpPost  extends AsyncTask<String, Void, String> {


            protected void onPreExecute() {
            }


            protected String doInBackground(String... arg0) {


                try {


                    URL url = new URL("Api url");

                    JSONObject postDataParams = new JSONObject();

/* HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();

            httpCon.setRequestProperty("Content-type", "application/json");
            httpCon.setRequestProperty("Accept", "application/json");
            httpCon.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
            httpCon.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJ1c2VyX2lkIjoxNCwiZW1haWwiOiJ0aGlhZ28uY2FtYXJnb0Bldm9sdXRpb25pdC5jb20uYnIiLCJmb3JldmVyIjpmYWxzZSwiaXNzIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIwN1wvYXBpXC92Mlwvc3lzdGVtXC9hZG1pblwvc2Vzc2lvbiIsImlhdCI6MTQ5NDE4NjA2MCwiZXhwIjoxNDk0MTg5NjYwLCJuYmYiOjE0OTQxODYwNjAsImp0aSI6ImM5N2VkMzY4MDU0MWQ5ZDI3OGJkZjAwNWYwMmMwYmY0In0.2j06THHfdJiBdwWOP1Dpkqs1Un2tSeVWa0NxVBpNxBo");
            httpCon.setRequestProperty("Authorization", "Basic  dGhpYWdvLmNhbWFyZ29AZXZvbHV0aW9uaXQuY29tLmJyOmluaWNpYWwyMDE3");
            httpCon.setRequestMethod("POST");
            httpCon.setReadTimeout(15000 *//* milliseconds *//*);
            httpCon.setConnectTimeout(15000 *//* milliseconds *//*);
            httpCon.setDoInput(true);
            httpCon.setDoOutput(true);*/


                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                    conn.setRequestProperty("Content-type", "application/json");
                    conn.setRequestProperty("Accept", "application/json");
                    conn.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                    conn.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.fb69q5ByrWAMhanFWMpye78KN7OxgYC0IGsdoGgUYps");
                    conn.setRequestProperty("Authorization", "Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                    //conn.setRequestProperty("-d", "{}");
                    conn.setRequestMethod("POST");
                    conn.setReadTimeout(15000 /* milliseconds */);
                    conn.setConnectTimeout(15000 /* milliseconds */);
                    conn.setDoInput(true);
                    conn.setDoOutput(true);



                    postDataParams.put("email", "mName");
                    postDataParams.put("password", "mNick");
                    postDataParams.put("dt_nascimento", "mData");
                    postDataParams.put("nu_cellphone", "mNumber");
                    postDataParams.put("password", "mPassword");
                    postDataParams.put("sexo", "mSexo");
                    postDataParams.put("tp_ativo", "mTpativo");


                    Log.e("resource", postDataParams.toString());




                    //postDataParams.put("password", "password");

                    JSONObject resource = new JSONObject();
                    JSONArray array = new JSONArray();
                    array.put(postDataParams);
                    resource.put("resource", array);

                    System.out.println(resource.toString());


                    conn.connect();

                    OutputStream os = conn.getOutputStream();
                    BufferedWriter writer = new BufferedWriter(
                            new OutputStreamWriter(os, "UTF-8"));
                    //writer.write(getPostDataString(postDataParams));
                    writer.write(resource.toString());

                    writer.flush();
                    writer.close();
                    os.close();

                    int responseCode = conn.getResponseCode();

                    if (responseCode == HttpsURLConnection.HTTP_OK) {

                        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                        StringBuffer sb = new StringBuffer("");
                        String line = "";

                        while ((line = in.readLine()) != null) {

                            sb.append(line);
                            break;
                        }

                        in.close();
                        return sb.toString();
                    } else {
                        return new String("false : " + responseCode);
                    }
                } catch (Exception e) {
                    return new String("Exception: " + e.getMessage());
                }
            }

            @Override
            protected void onPostExecute(String result) {
                Toast.makeText(getApplicationContext(), result,
                        Toast.LENGTH_LONG).show();

            }
        }

    }

Tenho um codigo que deveria fazer um "Post" via json ,mas o edittext não está convertendo para String,e não da nenhum erro no logcat ..Alguem tem ideia do erro?Deve ser algo idiota peço desculpas,mas sou novata em android.

public class PostTeste extends AppCompatActivity {


    private Button btnfincad;
    private EditText name,nick,email,password,number,sexo,tpativo;
   private String mName,mNick,mEmail,mPassword,mNumber,mSexo,mTpativo;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cadastro);

        btnfincad = (Button) findViewById(R.id.btnfincad);
        nick = (EditText) findViewById(R.id.etnick);
        email = (EditText)findViewById(R.id.Cemail);
        password = (EditText)findViewById(R.id.Cpassword);
        number = (EditText)findViewById(R.id.etnumcel);
        sexo = (EditText)findViewById(R.id.sexo);
        tpativo = (EditText)findViewById(R.id.tpativo);


        btnfincad.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                btnfincad.setOnClickListener(new View.OnClickListener()
                {
                    public void onClick(View v) {
                        new onbuttonclickHttpPost().execute();
                        name = (EditText) findViewById(R.id.etname);
                        String mName = name.getText().toString();
                        String mNick = nick.getText().toString();
                        String mEmail = email.getText().toString();
                        String mPassword = password.getText().toString();
                        String mNumber = number.getText().toString();
                        String mSexo = sexo.getText().toString();
                        String mTpativo = tpativo.getText().toString();


                    }

                     
                });
            }
        });
    }

            public class onbuttonclickHttpPost  extends AsyncTask<String, Void, String> {


                protected void onPreExecute() {
                }


                protected String doInBackground(String... arg0) {


                    try {


                        URL url = new URL("Api url");

                        JSONObject postDataParams = new JSONObject();
/*
                HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();

                httpCon.setRequestProperty("Content-type", "application/json");
                httpCon.setRequestProperty("Accept", "application/json");
                httpCon.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                httpCon.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJ1c2VyX2lkIjoxNCwiZW1haWwiOiJ0aGlhZ28uY2FtYXJnb0Bldm9sdXRpb25pdC5jb20uYnIiLCJmb3JldmVyIjpmYWxzZSwiaXNzIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIwN1wvYXBpXC92Mlwvc3lzdGVtXC9hZG1pblwvc2Vzc2lvbiIsImlhdCI6MTQ5NDE4NjA2MCwiZXhwIjoxNDk0MTg5NjYwLCJuYmYiOjE0OTQxODYwNjAsImp0aSI6ImM5N2VkMzY4MDU0MWQ5ZDI3OGJkZjAwNWYwMmMwYmY0In0.2j06THHfdJiBdwWOP1Dpkqs1Un2tSeVWa0NxVBpNxBo");
                httpCon.setRequestProperty("Authorization", "Basic  dGhpYWdvLmNhbWFyZ29AZXZvbHV0aW9uaXQuY29tLmJyOmluaWNpYWwyMDE3");
                httpCon.setRequestMethod("POST");
                httpCon.setReadTimeout(15000 *//* milliseconds *//*);
                httpCon.setConnectTimeout(15000 *//* milliseconds *//*);
                httpCon.setDoInput(true);
                httpCon.setDoOutput(true);*/


                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                        conn.setRequestProperty("Content-type", "application/json");
                        conn.setRequestProperty("Accept", "application/json");
                        conn.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                        conn.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.fb69q5ByrWAMhanFWMpye78KN7OxgYC0IGsdoGgUYps");
                        conn.setRequestProperty("Authorization", "Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                        //conn.setRequestProperty("-d", "{}");
                        conn.setRequestMethod("POST");
                        conn.setReadTimeout(15000 /* milliseconds */);
                        conn.setConnectTimeout(15000 /* milliseconds */);
                        conn.setDoInput(true);
                        conn.setDoOutput(true);



                        postDataParams.put("email", "mName");
                        postDataParams.put("password", "mNick");
                        postDataParams.put("dt_nascimento", "mData");
                        postDataParams.put("nu_cellphone", "mNumber");
                        postDataParams.put("password", "mPassword");
                        postDataParams.put("sexo", "mSexo");
                        postDataParams.put("tp_ativo", "mTpativo");


                        Log.e("resource", postDataParams.toString());




                        //postDataParams.put("password", "password");

                        JSONObject resource = new JSONObject();
                        JSONArray array = new JSONArray();
                        array.put(postDataParams);
                        resource.put("resource", array);

                        System.out.println(resource.toString());


                        conn.connect();

                        OutputStream os = conn.getOutputStream();
                        BufferedWriter writer = new BufferedWriter(
                                new OutputStreamWriter(os, "UTF-8"));
                        //writer.write(getPostDataString(postDataParams));
                        writer.write(resource.toString());

                        writer.flush();
                        writer.close();
                        os.close();

                        int responseCode = conn.getResponseCode();

                        if (responseCode == HttpsURLConnection.HTTP_OK) {

                            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                            StringBuffer sb = new StringBuffer("");
                            String line = "";

                            while ((line = in.readLine()) != null) {

                                sb.append(line);
                                break;
                            }

                            in.close();
                            return sb.toString();
                        } else {
                            return new String("false : " + responseCode);
                        }
                    } catch (Exception e) {
                        return new String("Exception: " + e.getMessage());
                    }
                }

                @Override
                protected void onPostExecute(String result) {
                    Toast.makeText(getApplicationContext(), result,
                            Toast.LENGTH_LONG).show();

                }
            }

        }
Fonte Link

Post via Json getstring erro

Tenho um codigo que deveria fazer um "Post" via json ,mas o edittext não está convertendo para String,e não da nenhum erro no logcat ..Alguem tem ideia do erro?Deve ser algo idiota peço desculpas,mas sou novata em android.

public class PostTeste extends AppCompatActivity {

private Button btnfincad;
private EditText name,nick,email,password,number,sexo,tpativo;

private String mName,mNick,mEmail,mPassword,mNumber,mSexo,mTpativo;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cadastro);

    btnfincad = (Button) findViewById(R.id.btnfincad);
    nick = (EditText) findViewById(R.id.etnick);
    email = (EditText)findViewById(R.id.Cemail);
    password = (EditText)findViewById(R.id.Cpassword);
    number = (EditText)findViewById(R.id.etnumcel);
    sexo = (EditText)findViewById(R.id.sexo);
    tpativo = (EditText)findViewById(R.id.tpativo);


    btnfincad.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            btnfincad.setOnClickListener(new View.OnClickListener()
            {
                public void onClick(View v) {
                    new onbuttonclickHttpPost().execute();
                    name = (EditText) findViewById(R.id.etname);
                    String mName = name.getText().toString();
                    String mNick = nick.getText().toString();
                    String mEmail = email.getText().toString();
                    String mPassword = password.getText().toString();
                    String mNumber = number.getText().toString();
                    String mSexo = sexo.getText().toString();
                    String mTpativo = tpativo.getText().toString();


                }

                
            });
        }
    });
}

        public class onbuttonclickHttpPost  extends AsyncTask<String, Void, String> {


            protected void onPreExecute() {
            }


            protected String doInBackground(String... arg0) {


                try {


                    URL url = new URL("Api url");

                    JSONObject postDataParams = new JSONObject();

/* HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();

            httpCon.setRequestProperty("Content-type", "application/json");
            httpCon.setRequestProperty("Accept", "application/json");
            httpCon.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
            httpCon.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJ1c2VyX2lkIjoxNCwiZW1haWwiOiJ0aGlhZ28uY2FtYXJnb0Bldm9sdXRpb25pdC5jb20uYnIiLCJmb3JldmVyIjpmYWxzZSwiaXNzIjoiaHR0cDpcL1wvMTkyLjE2OC4xLjIwN1wvYXBpXC92Mlwvc3lzdGVtXC9hZG1pblwvc2Vzc2lvbiIsImlhdCI6MTQ5NDE4NjA2MCwiZXhwIjoxNDk0MTg5NjYwLCJuYmYiOjE0OTQxODYwNjAsImp0aSI6ImM5N2VkMzY4MDU0MWQ5ZDI3OGJkZjAwNWYwMmMwYmY0In0.2j06THHfdJiBdwWOP1Dpkqs1Un2tSeVWa0NxVBpNxBo");
            httpCon.setRequestProperty("Authorization", "Basic  dGhpYWdvLmNhbWFyZ29AZXZvbHV0aW9uaXQuY29tLmJyOmluaWNpYWwyMDE3");
            httpCon.setRequestMethod("POST");
            httpCon.setReadTimeout(15000 *//* milliseconds *//*);
            httpCon.setConnectTimeout(15000 *//* milliseconds *//*);
            httpCon.setDoInput(true);
            httpCon.setDoOutput(true);*/


                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                    conn.setRequestProperty("Content-type", "application/json");
                    conn.setRequestProperty("Accept", "application/json");
                    conn.setRequestProperty("X-DreamFactory-Api-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88");
                    conn.setRequestProperty("X-DreamFactory-Session-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.fb69q5ByrWAMhanFWMpye78KN7OxgYC0IGsdoGgUYps");
                    conn.setRequestProperty("Authorization", "Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                    //conn.setRequestProperty("-d", "{}");
                    conn.setRequestMethod("POST");
                    conn.setReadTimeout(15000 /* milliseconds */);
                    conn.setConnectTimeout(15000 /* milliseconds */);
                    conn.setDoInput(true);
                    conn.setDoOutput(true);



                    postDataParams.put("email", "mName");
                    postDataParams.put("password", "mNick");
                    postDataParams.put("dt_nascimento", "mData");
                    postDataParams.put("nu_cellphone", "mNumber");
                    postDataParams.put("password", "mPassword");
                    postDataParams.put("sexo", "mSexo");
                    postDataParams.put("tp_ativo", "mTpativo");


                    Log.e("resource", postDataParams.toString());




                    //postDataParams.put("password", "password");

                    JSONObject resource = new JSONObject();
                    JSONArray array = new JSONArray();
                    array.put(postDataParams);
                    resource.put("resource", array);

                    System.out.println(resource.toString());


                    conn.connect();

                    OutputStream os = conn.getOutputStream();
                    BufferedWriter writer = new BufferedWriter(
                            new OutputStreamWriter(os, "UTF-8"));
                    //writer.write(getPostDataString(postDataParams));
                    writer.write(resource.toString());

                    writer.flush();
                    writer.close();
                    os.close();

                    int responseCode = conn.getResponseCode();

                    if (responseCode == HttpsURLConnection.HTTP_OK) {

                        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                        StringBuffer sb = new StringBuffer("");
                        String line = "";

                        while ((line = in.readLine()) != null) {

                            sb.append(line);
                            break;
                        }

                        in.close();
                        return sb.toString();
                    } else {
                        return new String("false : " + responseCode);
                    }
                } catch (Exception e) {
                    return new String("Exception: " + e.getMessage());
                }
            }

            @Override
            protected void onPostExecute(String result) {
                Toast.makeText(getApplicationContext(), result,
                        Toast.LENGTH_LONG).show();

            }
        }

    }