'How to use LocationRequest? Because direct constructor is not working nor .create()
I am trying to get current location in a map fragment but unable to do so because LocationRequest.create() is not wokring. Neither works:
LocationRequest l = new LocationRequest();
OR
LocationReuest l = LocationRequest.create();
My MapsFragment.java:
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationRequest;
public class MapsFragment extends SupportMapFragment {
LocationRequest mLocationRequest;
mLocationRequest = LocationRequest.create();
}
My build.gradle (app level):
dependencies {
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.github.niqo01.rxplayservices:rx-play-services-location:0.4.0'
}
I have cleaned and rebuilded the app but it doesn't works. Please give a solution for this or just a code to make sure I get current location on a google map in a fragment
Solution 1:[1]
You are using the wrong class.
instead of using the class LocationRequest that is part of android.location package write the following in your imports section:
import com.google.android.gms.location.LocationRequest;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |