Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void buttonLogin(View v){
- String url = "https://luiscm.000webhostapp.com/registar.php";
- JSONObject jsonBody = new JSONObject();
- StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>(){
- @Override
- public void onResponse(String response){
- try{
- JSONObject jsonoutput = new JSONObject(response);
- Toast.makeText(RegistarActivity.this, getResources().getString(R.string.userregistar), Toast.LENGTH_SHORT).show();
- if(jsonoutput.getString(Utils.param_status_pessoa).equals("1")){
- Intent i = new Intent(RegistarActivity.this, MainActivity.class);
- startActivity(i);
- }
- else{
- Toast.makeText(RegistarActivity.this, R.string.userexistente, Toast.LENGTH_SHORT).show();
- }
- } catch(JSONException ex){
- }
- }
- }, new Response.ErrorListener(){
- @Override
- public void onErrorResponse(VolleyError error){
- //Toast.makeText(RegistarActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
- }
- }){
- @Override
- protected Map<String,String> getParams(){
- nome = (EditText) findViewById(R.id.nomepessoa);
- username = (EditText) findViewById(R.id.usernamepessoa);
- password = (EditText) findViewById(R.id.passwordpessoa);
- String username1 = username.getText().toString();
- String password1 = password.getText().toString();
- String nome1 = nome.getText().toString();
- Map<String,String> params1 = new HashMap<>();
- params1.put("nome",nome1);
- params1.put("username",username1);
- params1.put("password",password1);
- return params1;
- }
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- Map<String,String> params = new HashMap<>();
- params.put("Content-type","application/x-www-form-urlencoded");
- return params;
- }
- };
- MySingleton.getInstance(this).addToRequestQueue(stringRequest);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement