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/login.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(MainActivity.this, jsonoutput.getString(Utils.param_status).toString() + jsonoutput.getString(Utils.param_id_user).toString() + jsonoutput.getString(Utils.param_id).toString() + jsonoutput.getString(Utils.param_nome).toString(), Toast.LENGTH_SHORT).show();
- Intent i = new Intent(MainActivity.this, MenuActivity.class);
- startActivity(i);
- } catch(JSONException ex){
- }
- }
- }, new Response.ErrorListener(){
- @Override
- public void onErrorResponse(VolleyError error){
- Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
- }
- }){
- @Override
- protected Map<String,String> getParams(){
- username = (EditText) findViewById(R.id.edituser);
- password = (EditText) findViewById(R.id.edit2);
- String username1 = username.getText().toString();
- String password1 = password.getText().toString();
- Map<String,String> params = new HashMap<>();
- params.put("username",username1);
- params.put("password",password1);
- return params;
- }
- @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