My location detection works BUT it doesn't work when I discoect the smartphone from the watch. Is there a way to still be able to check location but without the smartphone.
I used this tutorial for location detection: https://developer.android.com/training/articles/wear-location-detection.html
this is the code now:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addApi(Wearable.API) // used for data layer API
.addCoectionCallbacks(this)
.addOnCoectionFailedListener(this)
.build();
System.out.println("created request");
locationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(1000)
.setFastestInterval(500)
.setSmallestDisplacement(0);
System.out.println("created listener");
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
System.out.println("updating gps");
updateGps(location.getLatitude() + ","+location.getLongitude());
stopLocationUpdates();
}
};
LocationServices.FusedLocationApi
.requestLocationUpdates(mGoogleApiClient, locationRequest,locationListener )
.setResultCallback(new ResultCallback(){
@Override
public void onResult(@NonNull Result result) {
if (result.getStatus().isSuccess()) {
Log.d(TAG, "Successfully requested location updates");
} else {
Log.e(TAG,
"Failed in requesting location updates, "
+ "status code: "
+ result.getStatus().getStatusCode()
+ ", message: "
+ result.getStatus().getStatusMessage());
}
}
});
Is it possible that this will only be possible from the next major android wear update because I heard that smartwatches will be more independent.
