【发布时间】:2018-11-04 04:14:11
【问题描述】:
我正在使用 FusedLocationProviderClient` 获取当前设备位置
com.google.android.gms.tasks.Task<Location> location = mFusedLocationProviderClient.getLastLocation();
location.addOnCompleteListener(new OnCompleteListener<Location>() {
@Override
public void onComplete(@NonNull com.google.android.gms.tasks.Task<Location> task) {
if(task.isSuccessful()){
Location currentLocation = task.getResult();
Toast.makeText(getApplicationContext(),"Detecting current Location",Toast.LENGTH_LONG).show();
moveCamera(new LatLng(currentLocation.getLatitude(),currentLocation.getLongitude()),ZOOM,"My Location");
mUserLocalStore = new UserLocalStore(getApplicationContext());
db = FirebaseDatabase.getInstance();
mRef = db.getReference("Location");
mRef.setValue(String.valueOf(mUserLocalStore.getDetails().getEmail()+" "+currentLocation.getLatitude()+" ,"+String.valueOf(currentLocation.getLongitude())));
并在firebase中保存位置,如何在更改位置或指定时间段时将位置更新到firebase`
【问题讨论】:
标签: android firebase dictionary firebase-realtime-database location