【发布时间】:2013-10-09 11:17:44
【问题描述】:
我有一个实现GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener 的Service。
所以,当我创建Service 时,我会检查Google Play Services 是否可用,或者是否是正确的版本:
private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {
return true;
} else {
// Get the error code
GooglePlayServicesUtil
.getErrorDialog(resultCode, this, 0).show();// This won't work in a service
}
}//end
那么,如果我返回一个错误代码,我该如何响应它(向用户显示带有选项的 Dialog),因为我在 Service 内部?在这种情况下,最佳做法是什么?
【问题讨论】:
标签: android android-service google-play-services android-location