1
我试图做7天以来没有结果。问题是ResultCallback,geofencing我需要ResultCallback而LocationSettings我需要ResultCallback,有没有办法做到这一点? 我很欣赏一些技巧... 我使用谷歌最新的播放服务的支持:) 7.0 感谢Android新LocationSettings和Geofencing
public class GeofenceIntentService
extends IntentService
implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
ResultCallback<Status>, ResultCallback<LocationSettingsResult> {
// onResult for geofencing
public void onResult(Status status) {
Log.i(TAG, "onResult");
if (status.isSuccess()) {
Log.i(TAG, "status.isSuccess()");
} else {
String errorMessage = GeofenceErrorMessages.getErrorString(getApplicationContext(),
status.getStatusCode());
Log.e(TAG, errorMessage);
}
}
// onResult for LocationSettings
@Override
public void onResult(LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
Log.i(TAG, "All location settings are satisfied.");
startLocationUpdates();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
Log.i(TAG, "Location settings are not satisfied. Show the user a dialog to" +
"upgrade location settings ");
try {
// Show the dialog by calling startResolutionForResult(), and check the result
// in onActivityResult().
status.startResolutionForResult(BaseActivity.this, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
Log.i(TAG, "PendingIntent unable to execute request.");
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.i(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog " +
"not created.");
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
// Check for the integer request code originally supplied to startResolutionForResult().
case REQUEST_CHECK_SETTINGS:
switch (resultCode) {
case Activity.RESULT_OK:
Log.i(TAG, "User agreed to make required location settings changes.");
startLocationUpdates();
break;
case Activity.RESULT_CANCELED:
Log.i(TAG, "User chose not to make required location settings changes.");
break;
}
break;
}
}
}
你可以张贴一些代码,说明到目前为止你做了什么,并解释什么是不工作? –
是啊,看完这个问题后,我不知道你在问什么...... –
@亚历克斯贝克:下午我会提供一个样本... – geolyth