title: Android Fragment onAttach() deprecated
body: <p>I have updated my app to use the latest support library (version 23.0.0), I've found out that they deprecated the onAttach() function of the Fragment class.</p>
  
  <p>Instead of:</p>
  
  <pre><code>onAttach (Activity activity)
  </code></pre>
  
  <p>It's now:</p>
  
  <pre><code>onAttach (Context context)
  </code></pre>
  
  <p>As my app uses the activity passed before deprecation, a possible solution i think is:</p>
  
  <pre><code>@Override
  public void onAttach(Context context) {
      super.onAttach(context);
      activity = getActivity();
  }
  </code></pre>
  
  <p>Would that be the correct way to do it?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>If i run a device with API lower than 23, the new onAttach() is not even being called. I hope that this is not what they intended to do!</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Issue has been resolved with the latest updates to the SDK.</p>
  
  <p>I have tested on my API 22 device and onAttach(Context) is being called.</p>
  
  <p>Click <a href="https://code.google.com/p/android/issues/detail?id=183358" rel="noreferrer">here</a> to follow the bug report I've opened a couple of weeks ago and the answers from the guys at Google.</p>