question

StevenSquires-9060 avatar image
0 Votes"
StevenSquires-9060 asked StevenSquires-9060 answered

LocationRequest() is obsolete and deprecated

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?

dotnet-xamarin
· 15
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @StevenSquires-9060 , are you referring to class LocationRequest in Android? But according to the document, it hasn't been deprecated. You can also check the offical sample here: FusedLocationProvider/MainActivity.cs .


0 Votes 0 ·

The attached png file shows what Visual Studio 2019 shows me when I create a "new LocationRequest()". I followed your link and studied the code. This is very puzzling.93629-locationrequest-deprecated.png


0 Votes 0 ·

Also, my browser does not locate my location. It somewhere in California.

0 Votes 0 ·
Show more comments
JessieZhang-2116 avatar image
0 Votes"
JessieZhang-2116 answered JessieZhang-2116 commented

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.



image.png (95.7 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have one more question Jessie. My pixel emulator is still not starting in my current position. It does if I use my cell phone hardware, but it starts in California when I use the emulator. Any suggestions? Do I have a setting mis-configured?

0 Votes 0 ·

Hi @StevenSquires-9060 ,one thread, one problem . For the new problem, you can create a new thread, we are all willing to help you. :)

0 Votes 0 ·
StevenSquires-9060 avatar image
0 Votes"
StevenSquires-9060 answered

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]



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.