title: Send GPS coordinates to Android emulator using DDMS, telnet or any other means
body: <p>DDMS is not able to send location to the emulator. I have tried sending just the location from DDMS but still the emulator is not able to receive location.  Nothing appears on the DDMS log when I click the Send button.  </p>
  
  <p>I tried sending geo fix from telnet which returns OK but doesn't actually update the location, or if it does I can't read it via my application. </p>
  
  <p>The application works properly in the device, is able to capture test location details but not able to capture location data sent to the emulator either via DDMS or telnet.</p>
  
  <p>I am testing on Android 2.2 emulator. Can anyone let me know what is wrong?</p>
  
  <p>My app (below) is written in C# using Mono for Android and may need fixing (I'm a newbie to all things Android so I could have missed something).  OnLocationChanged(Location location) just doesn't seem to fire at all, as if the listener isn't properly defined.  Any help appreciated.  </p>
  
  <p>Note:  The first time I run this Activity the LocationManager.GetLastKnownLocation is null but the test provider stuff isn't accessed.   When I run it again GetLastKnowLocation is still null but the test provider stuff is accessed and set.  Weird. </p>
  
  <pre><code>[Activity(Label = "Location Demo")]
  public class LocationActivity : Activity, ILocationListener
  {
      private TextView _locationText;
      private LocationManager _locationManager;
      private StringBuilder _builder;
      private Geocoder _geocoder;
  
      protected override void OnCreate(Bundle savedInstanceState)
      {
          base.OnCreate(savedInstanceState);
          SetContentView(Resource.Layout.LocationActivity);
          _geocoder = new Geocoder(this);
          _locationText = FindViewById&lt;TextView&gt;(Resource.Id.TextView1);
          _locationManager = (LocationManager)GetSystemService(LocationService);
  
          if (_locationManager.GetLastKnownLocation("gps") == null)
          {
              _locationManager.AddTestProvider("gps", false, false, false, false, false, false, false, 0, 5);
              _locationManager.SetTestProviderEnabled("gps", true);
              Location loc = new Location("gps");
              loc.Latitude = 50;
              loc.Longitude = 50;
              _locationManager.SetTestProviderLocation("gps", loc);
          }
          Location lastKnownLocation = _locationManager.GetLastKnownLocation("gps");
  
          if (lastKnownLocation != null)
          {
              _locationText.Text += string.Format("Last known location, lat: {0}, long: {1}", lastKnownLocation.Latitude, lastKnownLocation.Longitude);
          }
          else
          {
              _locationText.Text += string.Format("Last location unknown");
          }
          _locationManager.RequestLocationUpdates("gps", 5000, 2, this);
      }
      public void OnLocationChanged(Location location)
      {
          _locationText.Text += string.Format("Location updated, lat: {0}, long: {1}", location.Latitude, location.Longitude);
      }
      public void OnProviderDisabled(string provider){}
      public void OnProviderEnabled(string provider){}
      public void OnStatusChanged(string provider, Android.Locations.Availability availability, Bundle extras){}
  
  }
  </code></pre>
  
  <p>Kudos to <a href="https://stackoverflow.com/users/170333/greg-shackles">https://stackoverflow.com/users/170333/greg-shackles</a> for getting me this far. </p>