Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. public class App63 extends Application
  2. {
  3. private static Api63 api63;
  4. private Retrofit retrofit;
  5.  
  6. @Override
  7. public void onCreate() {
  8. super.onCreate();
  9. retrofit = new Retrofit.Builder().baseUrl("http://www.chat.pareto-marketing.ru/").addConverterFactory(GsonConverterFactory.create()).build();
  10. api63 = retrofit.create(Api63.class);
  11. }
  12.  
  13. public static Api63 getApi() {
  14. return api63;
  15. }
  16. }
  17.  
  18. public interface Api63
  19. {
  20. @GET("getform")
  21. Call<ResponseBody> getData();
  22. }
  23.  
  24. Call<ResponseBody> list = App63.getApi().getData();
  25.  
  26. list.enqueue(new Callback<ResponseBody>() {
  27.  
  28. @Override
  29. public void onResponse(Call<ResponseBody> p1, Response<ResponseBody> p2)
  30. {
  31. try
  32. {
  33. Log.d("$", p2.body().string());
  34. }
  35. catch (IOException e)
  36. {}
  37. }
  38.  
  39. @Override
  40. public void onFailure(Call<ResponseBody> p1, Throwable p2)
  41. {
  42. // TODO: Implement this method
  43. }
  44. });
  45. }
  46. }
  47.  
  48. java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String okhttp3.ResponseBody.string()' on a null object reference
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement