Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. private Interfacestring Interfacestring;
  2. private RequestQueue requestQueue;
  3. private StringRequest request;
  4. private Interfacestring execinterface;
  5.  
  6. String usuario, senha, result;
  7.  
  8. Context context;
  9. Toast toast;
  10.  
  11. public MecanismoString (Context context, Interfacestring execinterface){
  12. this.context = context;
  13. this.Interfacestring = execinterface;
  14. }
  15.  
  16.  
  17.  
  18.  
  19. @Override
  20. public String doInBackground(String... params) {
  21.  
  22. Log.i("Script", "1 ->" + params[0]);
  23. Log.i("Script", "2 ->" + params[1]);
  24. Log.i("Script", "3 ->" + params[2]);
  25. Log.i("Script", "4 ->" + params[3]);
  26.  
  27. usuario = params[2];
  28. senha = params[3];
  29.  
  30. requestQueue = Volley.newRequestQueue(context);
  31.  
  32. request = new StringRequest(Request.Method.POST, params[1], new Response.Listener<String>() {
  33. @Override
  34. public void onResponse(String response) {
  35. try {
  36. JSONObject jsonObject = new JSONObject(response);
  37.  
  38. final String result = jsonObject.getString("perfil");
  39.  
  40.  
  41. } catch (JSONException e) {
  42. e.printStackTrace();
  43. }
  44.  
  45. }
  46. }, new Response.ErrorListener() {
  47. @Override
  48. public void onErrorResponse(VolleyError error) {
  49.  
  50. }
  51. }){
  52. @Override
  53. protected Map<String, String> getParams() throws AuthFailureError {
  54. HashMap<String, String> hashMap = new HashMap<String, String>();
  55. hashMap.put("login", usuario);
  56. hashMap.put("senha", senha);
  57.  
  58. return hashMap;
  59. }
  60. };
  61.  
  62. requestQueue.add(request);
  63.  
  64. return (result);
  65. }
  66.  
  67.  
  68. @Override
  69. protected void onPostExecute(String result) {
  70.  
  71. execinterface.carregarString(result);
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement