Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Interfacestring Interfacestring;
- private RequestQueue requestQueue;
- private StringRequest request;
- private Interfacestring execinterface;
- String usuario, senha, result;
- Context context;
- Toast toast;
- public MecanismoString (Context context, Interfacestring execinterface){
- this.context = context;
- this.Interfacestring = execinterface;
- }
- @Override
- public String doInBackground(String... params) {
- Log.i("Script", "1 ->" + params[0]);
- Log.i("Script", "2 ->" + params[1]);
- Log.i("Script", "3 ->" + params[2]);
- Log.i("Script", "4 ->" + params[3]);
- usuario = params[2];
- senha = params[3];
- requestQueue = Volley.newRequestQueue(context);
- request = new StringRequest(Request.Method.POST, params[1], new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- try {
- JSONObject jsonObject = new JSONObject(response);
- final String result = jsonObject.getString("perfil");
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- }
- }){
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- HashMap<String, String> hashMap = new HashMap<String, String>();
- hashMap.put("login", usuario);
- hashMap.put("senha", senha);
- return hashMap;
- }
- };
- requestQueue.add(request);
- return (result);
- }
- @Override
- protected void onPostExecute(String result) {
- execinterface.carregarString(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement