Android GoogleAppClient从不连接或失败。无所事事
试图连接到GoogleAppClient,但遇到了这样的情况:不但没有出错,反而什么也没发生Android GoogleAppClient从不连接或失败。无所事事,android,google-api-client,Android,Google Api Client,试图连接到GoogleAppClient,但遇到了这样的情况:不但没有出错,反而什么也没发生 public class Locator extends Activity implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { GoogleA
public class Locator
extends Activity
implements
LocationListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_atmbranch_locator);
// Create an instance of GoogleAPIClient.
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
}
@Override
protected void onStart(){
mGoogleApiClient.connect();
super.onStart();
// Note: This does get called
}
@Override
protected void onStop() {
mGoogleApiClient.disconnect();
super.onStop();
}
@Override
public void onLocationChanged(Location location) {
// This never gets called
}
@Override
public void onConnected(@Nullable Bundle bundle) {
// This never gets called
}
@Override
public void onConnectionSuspended(int i) {
// This never gets called
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
// This never gets called
}
}
你在清单中添加权限了吗?是的,我在清单中有这样的内容:“它直接在下面,在外面,好吧,我想这可能是Android Studio的一些奇怪的断点问题。重新启动后我再次尝试,效果良好。你在清单中添加权限了吗?是的,我在清单中有这样的内容:“它直接在下面,在外面,好的,我想这可能是Android Studio的一些奇怪的断点问题。重启后我又试了一次,效果很好。