Advertisement
Guest User

dsff

a guest
Apr 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. public void buttonLogin(View v){
  2. String url = "https://luiscm.000webhostapp.com/registar.php";
  3. JSONObject jsonBody = new JSONObject();
  4.  
  5. StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>(){
  6. @Override
  7. public void onResponse(String response){
  8. try{
  9. JSONObject jsonoutput = new JSONObject(response);
  10. Toast.makeText(RegistarActivity.this, getResources().getString(R.string.userregistar), Toast.LENGTH_SHORT).show();
  11. if(jsonoutput.getString(Utils.param_status_pessoa).equals("1")){
  12. Intent i = new Intent(RegistarActivity.this, MainActivity.class);
  13. startActivity(i);
  14. }
  15. else{
  16. Toast.makeText(RegistarActivity.this, R.string.userexistente, Toast.LENGTH_SHORT).show();
  17. }
  18.  
  19. } catch(JSONException ex){
  20.  
  21. }
  22. }
  23. }, new Response.ErrorListener(){
  24. @Override
  25. public void onErrorResponse(VolleyError error){
  26. //Toast.makeText(RegistarActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
  27. }
  28. }){
  29. @Override
  30. protected Map<String,String> getParams(){
  31.  
  32. nome = (EditText) findViewById(R.id.nomepessoa);
  33. username = (EditText) findViewById(R.id.usernamepessoa);
  34. password = (EditText) findViewById(R.id.passwordpessoa);
  35.  
  36.  
  37. String username1 = username.getText().toString();
  38. String password1 = password.getText().toString();
  39. String nome1 = nome.getText().toString();
  40.  
  41. Map<String,String> params1 = new HashMap<>();
  42. params1.put("nome",nome1);
  43. params1.put("username",username1);
  44. params1.put("password",password1);
  45.  
  46. return params1;
  47. }
  48.  
  49. @Override
  50. public Map<String, String> getHeaders() throws AuthFailureError {
  51. Map<String,String> params = new HashMap<>();
  52. params.put("Content-type","application/x-www-form-urlencoded");
  53. return params;
  54. }
  55. };
  56.  
  57. MySingleton.getInstance(this).addToRequestQueue(stringRequest);
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement