title: how can getActivity() be used to return context in a fragment class?
body: <p>I found some example code that does not make sense,   this.getActivity() method is used in the code shown below. in the parameters for the CursorLoader() method, the first parameter is context, and this.getActivity() is used here where context is needed.  why is it used in this example when it is clearly an error.</p>
  
  <p>android documentation states that for a fragment object in the example, getActivity() is supposed to return an activity object, not a context object.  since the first parameter is a context, how is it possible to use the getActivity() to return a context when is does not do that?</p>
  
  <p>from android documentation</p>
  
  <p>getActivity()</p>
  
  <p>return type: final activity</p>
  
  <p>Return the Activity this fragment is currently associated with.</p>
  
  <p><a href="http://developer.android.com/reference/android/app/Fragment.html" rel="nofollow">http://developer.android.com/reference/android/app/Fragment.html</a></p>
  
  <p>sample code</p>
  
  <pre><code>   public class YourFragment extends Fragment
    implements LoaderCallbacks&lt;Cursor&gt; {
  
    // more code......
  
   public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
    CursorLoader loader = new CursorLoader(
       this.getActivity(), // &lt;--- context is needed here
       SOME_CONTENT_URI, 
       projection, 
       selection, 
       selectionArgs, 
       sortOrder);
  return loader;
  }
  </code></pre>