title: Xamarin.Essentials "The current Activity can not be detected. Ensure that you have called Init in your Activity or Application class."
body: <p>My application gives an error:</p>
  
  <blockquote>
    <p>The current Activity can not be detected. Ensure that you have called Init in your Activity or Application class.</p>
  </blockquote>
  
  <p>I use the emulator Genymotion. GPS enabled</p>
  
  <pre><code>public async Task btnAdd_Click()
      {
          try
          {
              var request = new GeolocationRequest(GeolocationAccuracy.Medium);
              var location = await Geolocation.GetLocationAsync(request);
  
              if (location != null)
              {
                  string note = "GPS: Latitude-" + location.Latitude + " Longitude-" + location.Longitude;
              }
          }
          catch (Exception ex)
          {
              // Unable to get location
          }
      }
  </code></pre>