我需要在TextView上访问我的应用程序Latitude。所以,我在位置代码中使用,我在android 5中使用,并且我把我的Key值,放GPS并没有任何反应。
所以我在MainActivity中的代码是:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
txtOutput = (TextView) findViewById(R.id.txtOutput);
}
@Override
public void onConnected(Bundle bundle) {
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(10); // Update location every second
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
@Override
public void onConnectionSuspended(int i) {
Log.i(LOG_TAG, "GoogleApiClient connection has been suspend");
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(LOG_TAG, "GoogleApiClient connection has failed");
}
@Override
public void onLocationChanged(Location location) {
Log.i(LOG_TAG, location.toString());
// txtOutput.setText(location.toString());
txtOutput.setText(Double.toString(location.getLatitude()));
所以当我看到我的应用程序时,我没有得到谷歌纵横,我应该做什么?
感谢敌人帮助:)