Reputation: 86
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
Upvotes: 1
Views: 557
Reputation: 189
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;
Upvotes: 1