Guest User

Untitled

a guest
Dec 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. Bitmap photo = (Bitmap)data.getExtras().get("data");
  2. photo = Bitmap.createScaledBitmap(photo, 800, 1422, false);
  3. ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  4. photo.compress(Bitmap.CompressFormat.PNG, 100, bytes);
  5.  
  6. byte[] imageArray = bytes.toByteArray();
  7.  
  8. String imageAsString = Base64.encodeToString(imageArray, Base64.DEFAULT);
  9.  
  10. private String InsertpayKeyMachineImage(String url)
  11. {
  12. HttpClient client = buildHttpClient();
  13. HttpPost request = new HttpPost(url);
  14. HttpResponse response = null;
  15. String responseString = "";
  16.  
  17. try
  18. {
  19. System.out.println("VOU PARA O SERVIDOR");
  20. JSONObject jsonObject = this.setHeadersAndbuildJSONObject(request);
  21.  
  22. System.out.println("vou levar 1 - " + sessionID);
  23. System.out.println("vou levar 2 - " + data[0]);
  24. System.out.println("vou levar 3 - " + data[1]);
  25.  
  26. jsonObject.put("SessionGUID", sessionID);
  27. jsonObject.put("MacAddress", data[0]);
  28. jsonObject.put("imageAsBytes", data[1]);
  29.  
  30. responseString = this.executeRequest(jsonObject, request, response, client);
  31. System.out.println("VIM DO SERVIDOR " + responseString.toString());
  32.  
  33. }
  34. catch (Exception e)
  35. {
  36. System.out.println("ERRO " + e.getMessage());
  37. }
  38. return responseString;
  39. }
Add Comment
Please, Sign In to add comment