我有一个LocationReceiver
,它使用FusedLocationProviderApi.KEY_LOCATION_CHANGED
从一个Intent
中提取一个Location
。但现在KEY_LOCATION_CHANGED
已经被弃用了,我应该将其更改为什么?
当前代码:
@Override
public void onReceive(Context context, Intent intent) {
final Location location = (Location) intent.getExtras().get(FusedLocationProviderApi.KEY_LOCATION_CHANGED);
if (location != null) {
float accuracy = location.getAccuracy();
Log.d(LocationReceiver.class.getSimpleName(), "*** Accuracy is: " + accuracy + " ***");
} else {
Log.d(LocationReceiver.class.getSimpleName(), "*** location object is null ***");
}
}
hasResult
中得到了 false。你有什么想法为什么会这样? - Don Box