I found two types of question like this one on SO, but both have no answers.
I'm using FusedLocationProviderClient
to get the location of my device. I've lunched a background service to get the location using requestLocationUpdates()
.
Even when the application is in foreground, the returned latitude and longitude of the methods aren't changing.
Here's a snippet of how I'm using the class:
private FusedLocationProviderClient fusedLocationClient
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
fusedLocationClient.requestLocationUpdates(new LocationRequest(), locationCallback, Looper.getMainLooper());
locationCallback
is just a method which will print the Longitude and Latitude on the console.
All permissions are granted and I'm checking for the permissions in my manifest. Here's the permissions I've added:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity android:name=".HomeActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".LocationService" />
</application>
LocationService
is the service where I'm trying to get the location.
Anyone have an idea where's the issue?? I've been stuck for hours!