I am getting lat-long using GPS tracker but I am not getting my exact current location what I am getting is location 50 meter away from my current location I am using GPS Tracker only.each and every answer will be appreciable.my location is not getting varied from device to device as per mentioned in previous question.and i did not get any helpful answer their.
Asked
Active
Viewed 534 times
-3
-
2could it be something to do with accuracy ?! ,i hope you know this https://developer.android.com/reference/android/location/Location.html#getAccuracy() – himel Dec 05 '17 at 04:52
-
Possible duplicate of [can't find the exact current location in android](https://stackoverflow.com/questions/23889834/cant-find-the-exact-current-location-in-android) – Shailendra Madda Dec 05 '17 at 04:53
3 Answers
1
Use google client api for accurate location
you can refer- https://www.androidhive.info/2015/02/android-location-api-using-google-play-services/

Shivam Oberoi
- 1,447
- 1
- 9
- 18
-
i already implemented this example but not getting exact location .thanks. – Ankesh Roy Dec 05 '17 at 05:13
0
You can use FusedLocationProviderClient from Google location api just apply location library in gradle(app level).
compile 'com.google.android.gms:play-services-location:11.6.0'
and at the bottom of app level gradle add this line
apply plugin: 'com.google.gms.google-services'
Here is my code in mainActivity
public class MainActivity extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
FusedLocationProviderClient mFusedLocationClient;
private static final String TAG="Logs Details";
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
buildGoogleApiClient();
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onCreate() {
super.onCreate();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
@Override
public void onConnected(@Nullable Bundle bundle) {
Log.e(TAG,"app is connected");
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(10000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
}
}
LocationCallback mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
for (Location location : locationResult.getLocations()) {
mLastLocation = location;
Log.e("latitude",location.latitude);
Log.e("longitude",location.longitude);
}
}
};
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
}
Hope this helps.:)

AkashK
- 201
- 1
- 4
- 13
-
I am using fused API but not getting exact lat long all the time but getting much better then GPS . lat long getting only up to 7 decimal point using fused API can i get decimal point of lat long more then 7 using fused API. – Ankesh Roy Dec 05 '17 at 10:09
-
It will not give always the exact lat lang but it's more accurate as per my experience – AkashK Dec 05 '17 at 10:11
0
Using Fused location api of google we can get more exact lat and long but not 100% always.Fused location api is better then GPS tracker.

Ankesh Roy
- 278
- 2
- 8
- 33