title: What could cause Retrofit to ignore method invocation?
body: <p>I have ran into a strange behavior. My app has a main activity which consists of navdrawer layout and the default list fragment. The list fragment uses Retrofit client to fetch contents. The detail view is shown when a list item is selected. On a small screen, the detail view is loaded through a separate activity. That activity also uses a Retrofit client to fetch detailed information. Then, there is one option that can be selected from navdrawer that spawns a new activity. That activity too uses Retrofit client to send out data.</p>
  
  <p>The list and detail activities invoke Retrofit methods just fine. I can see the logs and things are working as expected. However, the third activity, which is opened through a navigation option, attempts to invoke Retrofit client methods that are ignored by Retrofit.</p>
  
  <p>In all instances, the Retrofit client is instantiated in the same way:</p>
  
  <pre><code>protected ServerApi buildApi(String serverEndpoint) {
      Gson gson = new GsonBuilder()
              .create();
  
      RestAdapter restAdapter = new RestAdapter.Builder()
              .setLog(new AndroidLog("ServerApi"))
              .setLogLevel(RestAdapter.LogLevel.FULL)
              .setEndpoint(serverEndpoint)
              .setErrorHandler(new ApiErrorHandler())
              .setConverter(new GsonConverter(gson))
              .build();
  
      return restAdapter.create(ServerApi.class);
  }
  </code></pre>
  
  <p>In the list and detail activities, I can see verbose Retrofit log entries. However, when I make a call to the similarly constructed Retrofit client in the third activity, no logs go out, no error is thrown, logcat doesn't print anything. Its almost like the invocation is ignored.</p>
  
  <p>I am sure that server end point is properly set and I also ensure that call is executed. At first, I thought that this may be due to creation of client happening in <code>onCreate</code> and executed on a separate thread. However, making a test invocation right after client creation doesn't produce any result.</p>
  
  <p>Does anyone know what may cause such odd behavior just in one activity and not the rest?</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>Yes, I tried logging everywhere. My more desperate Retrofit client build looked like this:</p>
  
  <pre><code>protected class ApiErrorHandler implements ErrorHandler {
      @Override
      public Throwable handleError(RetrofitError cause) {
          Log.e(TAG, "Got API error " + cause);
  
          Response r = cause.getResponse();
          Throwable throwable = null;
  
          if (r == null) {
              return cause;
          }
  
          // Try to interpret the response
          String responseBody = new String(((TypedByteArray) r.getBody()).getBytes());
          Gson gson = new GsonBuilder().create();
          BaseResponse response = null;
  
          try {
              response = gson.fromJson(responseBody, BaseResponse.class);
          }
          catch (Exception e) {
              Log.e(TAG, "Could not parse the error response:" + e.getMessage());
          }
  
          return new ServerApiException(response.getErrorMessage());
      }
  }
  
  protected class ApiRequestInterceptor implements RequestInterceptor {
      @Override
      public void intercept(RequestFacade request) {
          Log.d(TAG, "Intercepted API request: " + request.toString());
      }
  }
  
  RestAdapter restAdapter = new RestAdapter.Builder()
      .setLog(new AndroidLog("ServerApi"))
      .setLogLevel(RestAdapter.LogLevel.FULL)
      .setEndpoint(mServerUrl)
      .setErrorHandler(new ApiErrorHandler())
      .setConverter(new GsonConverter(gson))
      .setRequestInterceptor(new ApiRequestInterceptor())
      .setProfiler(new Profiler() {
          @Override
          public Object beforeCall() {
              Log.d("RetrofitProfiler", "Before call to retrofit");
              return null;
          }
  
          @Override
          public void afterCall(Profiler.RequestInformation requestInfo, long elapsedTime, int statusCode, Object beforeCallData) {
              Log.d("RetrofitProfiler", String.format("HTTP %d %s %s (%dms)",
                      statusCode, requestInfo.getMethod(), requestInfo.getRelativePath(), elapsedTime));
          }
      })
      .build();
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Ok, I was wrong but didn't know that Retrofit relied at least on one subscriber to be present. I guess it makes sense, now that I think about it... but its not fire-and-forget.</p>
  
  <p>What I was doing wrong:</p>
  
  <pre><code>mClient = new ServerClient(mServerEndpoint, mAccountToken);
  mUvClient.getFeed(mFeedId);
  </code></pre>
  
  <p>This is the part I didn't know. You need to subscribe to the observable in order for it to execute:</p>
  
  <pre><code>mClient = new ServerClient(mServerEndpoint, mAccountToken);
  mUvClient.getFeed(mFeedId)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(new Subscriber&lt;FeedInfo&gt;() {
          @Override
          public void onNext(FeedInfo feedInfo) {
              Log.d(TAG, "on Next");
          }
  
          @Override
          public void onCompleted() {
              Log.d(TAG, "on completed");
          }
  
          @Override
          public void onError(Throwable e) {
              Log.d(TAG, "on error");
          }
      });
  </code></pre>
  
  <p>This produces the expected Retrofit verbose logs and result. Anyway, I hope this helps someone.</p>