title: Retrofit2 in Android Fragment how to implement correctly?
body: <p>I'm using Retrofit 2 to consume an API. I have a service (interface) which returns a list:</p>
  <pre><code>@GET(&quot;atenciones&quot;)
  Call&lt;List&lt;Atencion&gt;&gt; getAtenciones(@Query(&quot;medico_id&quot;) int id, @Query(&quot;date1&quot;) String date1, @Query(&quot;date2&quot;) String date2)
  </code></pre>
  <p>Where should I do the request? In the <code>MainActivity</code> which contains the <code>Fragment</code> and send the result list using <code>Bundle</code>? or should do the request in the Fragment? this is a list not a single object. Which is the correct way?</p>
  <h1>Edit</h1>
  <p>Try to call retrofit in Fragment, this is my code:</p>
  <pre><code>public class FragmentRendicion extends Fragment {
  
  private LinearLayoutManager layoutManager;
  View rootView;
  APIService api;
  
  public FragmentRendicion() {
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      rootView = inflater.inflate(R.layout.fragment_rendicion, container, false);
      api= ApiUtils.getAPIService();
          getAtenciones();
      return rootView;
  }
  
  private void getAtenciones() {
  //using static parameters
      Call&lt;List&lt;Atencion&gt;&gt; call= api.getAtenciones(293,&quot;2014-10-13&quot;,&quot;2014-10-13&quot;);
      call.enqueue(new Callback&lt;List&lt;Atencion&gt;&gt;() {
          @Override
          public void onResponse(Call&lt;List&lt;Atencion&gt;&gt; call, Response&lt;List&lt;Atencion&gt;&gt; response) {
              System.out.println(&quot;estamos aquiiii &quot;+response.message());
              List&lt;Atencion&gt; atenciones= response.body();
              layoutManager= new LinearLayoutManager(getActivity());
              RecyclerView recycler= (RecyclerView)rootView.findViewById(R.id.rvRendicion);
              recycler.setLayoutManager(layoutManager);
              RvRendicionAdapter rvAdapter= new RvRendicionAdapter(atenciones);
              recycler.setAdapter(rvAdapter);
  
  
          }
  
          @Override
          public void onFailure(Call&lt;List&lt;Atencion&gt;&gt; call, Throwable t) {
              System.out.println(&quot;FALLOOOOO:  &quot;+t.getMessage());//HERE RETUNRS NULL
          }
      });
  
  }
  }
  </code></pre>
  <p>Can someone tell me is if it correct way to call retrofit2 in fragment?</p>