LocationRequest() is obsolete and deprecated

StevenSquires-9060 21 Reputation points
2021-05-04T00:51:20.337+00:00

I was building my Geolocation Xamarin App and recently found out upon trying to create a "mLocationRequest = new LocationRequest()" that LocationRequest() has been deprecated. Does anyone know how or what code to replace it with?

Developer technologies | .NET | Xamarin
{count} votes

Accepted answer
  1. JessieZhang-MSFT 7,716 Reputation points Microsoft External Staff
    2021-05-25T09:12:17.983+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    Yes, the LocationRequest constructor is deprecated. You can use its static method:
    99427-image.png

    So, you can change your code like this:

        void CreateLocationRequest()  
        {  
           // mLocationRequest = new LocationRequest();  
            mLocationRequest = LocationRequest.Create();  
    
            mLocationRequest.SetInterval(UPDATE_INTERVAL);  
            mLocationRequest.SetFastestInterval(FASTEST_INTERVAL);  
            mLocationRequest.SetPriority(LocationRequest.PriorityHighAccuracy);  
            mLocationRequest.SetSmallestDisplacement(DISPLACEMENT);  
            locationClient = LocationServices.GetFusedLocationProviderClient(this);  
        }  
    

    Best Regards,

    Jessie Zhang

    ---
    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. StevenSquires-9060 21 Reputation points
    2021-06-03T03:07:00.473+00:00

    Jessie,

    I've run into another deprecated Xamarin/Google/Android Nuget. Do you know of a workaround for using the "PlaceAutoComplete.IntentBuilder" service in the Xamarin.GooglePlayServices.Places API?

    Here's a code sample:
    private void LayoutDestination_Click(object sender, EventArgs e)
    {
    Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.ModeOverlay)
    .Build(this);
    StartActivityForResult(intent, 2);
    }

        private void LayoutPickup_Click(object sender, EventArgs e)  
        {  
            Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.ModeOverlay)  
                .Build(this);  
            StartActivityForResult(intent, 1);  
        }  
    

    My Warning messages say, 'PlaceAutocomplete' is obsolete: 'This class is obsolete in this android platform'.

    In my emulator, Google can't find the address entered.101855-placeautocomplete-deprecated.png![101868-placeautocomplete-deprecated.png][2]

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.