Java 类LocationSettingsStates在接收位置请求时做什么?
在这些文档中,我将介绍如何接收位置请求,我注意到这两段代码中有两件不同寻常的事情:Java 类LocationSettingsStates在接收位置请求时做什么?,java,android,google-api,location,Java,Android,Google Api,Location,在这些文档中,我将介绍如何接收位置请求,我注意到这两段代码中有两件不同寻常的事情: result.setResultCallback(new ResultCallback<LocationSettingsResult>() { @Override public void onResult(LocationSettingsResult result) { final Status status = result.getStatus();
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
final LocationSettingsStates = result.getLocationSettingsStates(); //<--This line I don't understand
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can initialize location
// requests here.
...
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. But could be fixed by showing the user
// a dialog.
try {
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
status.startResolutionForResult(
OuterClass.this,
REQUEST_CHECK_SETTINGS);
} catch (SendIntentException e) {
// Ignore the error.
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// Location settings are not satisfied. However, we have no way to fix the
// settings so we won't show the dialog.
...
break;
}
}
});
result.setResultCallback(新的ResultCallback(){
@凌驾
公共void onResult(位置设置结果){
最终状态状态=result.getStatus();
final-LocationSettingsStates=result.getLocationSettingsStates();//第一行肯定是一个输入错误;它应该类似于:
final LocationSettingsStates states = result.getLocationSettingsStates();
是的,这两个地方都没有使用它,这很奇怪,但是你可以调用它,比如isbleausable()
,来确定现在到底有什么存在和可用。在后一种情况下,它是在尝试解析后可用的内容。第一行肯定是一个输入错误;它应该是这样的:
final LocationSettingsStates states = result.getLocationSettingsStates();
是的,这两个地方都不使用它,这很奇怪,但是你可以调用它,比如isbleausable()
,来确定现在到底有什么存在和可用。在后一种情况下,它是在尝试解析之后可用的