Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Services service = retrofit.create(Services.class);
  2.  
  3. Call<Device> requestDevice = service.deviceAdd(id_Device);
  4.  
  5. requestDevice.enqueue(new Callback<Device>() {
  6. @Override
  7. public void onResponse(Call<Device> call, Response<Device> response) {
  8. //verifico se esta tendo resposta
  9. try {
  10. if (!response.isSuccessful()) {
  11. Log.i("Code", "Codigo: " + response.code());
  12. if(response.code() != 200){
  13. throw new Exception(response.body().toString());
  14.  
  15. }else{
  16. Log.i("code","Codigo: "+ response.code());
  17. }
  18. } else {
  19. Device aparelho = response.body();
  20. Log.i("test", aparelho.toString());
  21.  
  22. }
  23. }catch(Exception e){
  24. Log.e("erro", e.getMessage() );
  25.  
  26. }
  27. }
  28.  
  29. @Override
  30. public void onFailure(Call<Device> call, Throwable t) {
  31. Log.e("erro", t.getMessage() );
  32. }
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement