title: Receive ResultCallback from fragment
body: <p>I'm trying to get weather information using Awareness.API. Upon checking a checkbox, my code will retrieve the user's weather. Here's my code:</p>
  
  <pre><code>private GoogleApiClient mGoogleApiClient;    
  float temperature, temperatureFeelsLike;
  int humidity;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
              .addApi(Awareness.API).build();
      mGoogleApiClient.connect();
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
      chkOnLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked){
                  if (ContextCompat.checkSelfPermission(getActivity(),android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                      ActivityCompat.requestPermissions(getActivity(),new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},12345);
                  }
  
                  Awareness.SnapshotApi.getWeather(mGoogleApiClient)
                  .setResultCallback(new ResultCallback&lt;WeatherResult&gt;() {
                      @Override
                      public void onResult(@NonNull WeatherResult weatherResult) {
                          Weather weather = weatherResult.getWeather();
                          temperature = weather.getTemperature(Weather.CELSIUS);
                          temperatureFeelsLike = weather.getFeelsLikeTemperature(Weather.CELSIUS);
                          humidity = weather.getHumidity();
                          Log.v(FILE_NAME,"get temperature: " + temperature + ", " + temperatureFeelsLike + ", " + humidity);
                      }
                  });
              }
          }
      }
  }
  </code></pre>
  
  <p>Now the code above works as intended without any problem. But now since I'm calling the Weather api from many places, so I decided to put the code to retrieve it in another class, looking like this.</p>
  
  <pre><code>public class GetWeather {
  
      private GoogleApiClient mGoogleApiClient;
      private Activity mActivity;
      ObjWeather myWeather;
  
      public GetWeather(Activity activity){
          mActivity = activity;
          mGoogleApiClient = new GoogleApiClient.Builder(mActivity)
                  .addConnectionCallbacks(this)
                  .addApi(Awareness.API).build();
          mGoogleApiClient.connect();
  
          if (ContextCompat.checkSelfPermission(mActivity,android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
              ActivityCompat.requestPermissions(mActivity,new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},12345);
          }
      }
  
      @SuppressWarnings({"MissingPermission"})
      public ObjWeather getMyWeather(){
          Awareness.SnapshotApi.getWeather(mGoogleApiClient)
              .setResultCallback(new ResultCallback&lt;WeatherResult&gt;() {
                  @Override
                  public void onResult(@NonNull WeatherResult weatherResult) {
                      Weather weather = weatherResult.getWeather();
                      myWeather.setTemperature(weather.getTemperature(Weather.CELSIUS));
                      myWeather.setTemperatureFeelsLike(weather.getFeelsLikeTemperature(Weather.CELSIUS));
                      myWeather.setHumidity(weather.getHumidity());
                  }
              });
  
          return myWeather;
      }
  }
  </code></pre>
  
  <p>And here's how I called the code above from my fragment which holds the checkbox;</p>
  
  <pre><code>GetWeather getWeather;
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      getWeather = new GetWeather(getActivity());
  
      chkOnLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked){
                  ObjWeather myWeather = getWeather.getMyWeather();
  
                  temperature = myWeather.getTemperature();
                  temperatureFeelsLike = myWeather.getTemperatureFeelsLike();
                  humidity = myWeather.getHumidity();
                  Log.v(FILE_NAME,"get temperature: " + temperature + ", " + temperatureFeelsLike + ", " + humidity);
              }
          }
      });
  }
  </code></pre>
  
  <p>In the 2nd method, I was never be able to get the weather values; it will always return 0. How do I properly get the weather value there?</p>