Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RegistarAnimal(View v){
- String url = "https://luiscm.000webhostapp.com/registaranimal.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(RegistarAnimalActivity.this, jsonoutput.getString(Utils.param_status_animal).toString(), Toast.LENGTH_SHORT).show();
- /* Intent i = new Intent(RegistarAnimalActivity.this, MenuActivity.class);
- startActivity(i);*/
- } catch(JSONException ex){
- }
- }
- }, new Response.ErrorListener(){
- @Override
- public void onErrorResponse(VolleyError error){
- Toast.makeText(RegistarAnimalActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
- }
- }){
- @Override
- protected Map<String,String> getParams(){
- android.content.SharedPreferences sharedPref = getSharedPreferences(getString(R.string.shared_pref_1), Context.MODE_PRIVATE);
- String id_user = sharedPref.getString(Utils.id_user,null);
- nome = (EditText) findViewById(R.id.nome);
- username = (EditText) findViewById(R.id.username);
- password = (EditText) findViewById(R.id.password);
- 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);
- params1.put("id_user",id_user);
- 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