我在Google Play服務庫中遇到了一些問題。Android Studio上的Google API錯誤
我已經導入這些文件:
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
我得到的錯誤在整個項目的 「GoogleApiClient」: -
public class MainActivity extends FragmentActivity implements LocationListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
在這裏我得到的錯誤與locationClient/LocationServices/GoogleApiClient
locationClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
這裏是「locationClient」的錯誤
@Override
public void onStop() {
// If the client is connected
if (locationClient.isConnected()) {
stopPeriodicUpdates();
}
// After disconnect() is called, the client is considered "dead".
locationClient.disconnect();
super.onStop();
}
/*
* Called when the Activity is restarted, even before it becomes visible.
*/
@Override
public void onStart() {
super.onStart();
// Connect to the location services client
locationClient.connect();
}
在這裏,我得到錯誤 「onConnectionSuspended」
@Override
public void onConnectionSuspended(int i) {
Log.i(Application.APPTAG, "GoogleApiClient connection has been suspend");
}
記住:有一個錯誤?添加完整的logcat – piotrek1543