Building Google api client within Fragment
<p>I am getting an error while building google api client in a fragment. The error I am getting is;</p>

<pre><code>   java.lang.ClassCastException: net.janusjanus.we4x4_v1.upload cannot be cast to com.google.android.gms.common.api.GoogleApiClient$OnConnectionFailedListener
</code></pre>

<p>I have implemented <code>GoogleApiClient.ConnectionCallbacks</code>, <code>GoogleApiClient.OnConnectionFailedListener</code>, and <code>LocationListener</code></p>

<p>and requesting the build as following;</p>

<pre><code>         mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener((GoogleApiClient.OnConnectionFailedListener) getActivity())
            .addApi(LocationServices.API)
            .build();
</code></pre>

<p>first I had a problem declaring the new GoogleApiClient.Builder where I declared it as ;</p>

<pre><code>          mGoogleApiClient = new GoogleApiClient.Builder(this)
</code></pre>

<p>underlined as an error, thus I had to try several ways to declare it, with <code>getActivity()</code> and <code>getContext()</code>. but I got the same error ?</p>

<p>Any idea on what I am doing wrong here and the correct way ?</p>