title: GPS on Android problem
body: <p>I have been trying for about 3 days to solve this problem and I haven't found a solution so far. I am trying to get my location through GPS. 
  It doesn't seem to receive the coordonates that I try to send through cmd.exe or the Emulator Control in the DDMS. Moreover, it restarts the emulator. The code that I have been trying is below. If someone can help me then please do because I don't find any solution to this problem. Thank you!</p>
  
  <pre><code>import android.app.Activity;
  import android.content.Context;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.widget.TextView;
  
  public class Check_Location extends Activity {
  
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  LocationManager locationManager = (LocationManager)       this.getSystemService(Context.LOCATION_SERVICE);
  
  LocationListener locationListener = new LocationListener() {
  public void onLocationChanged(Location location) {
  
  TextView tv=(TextView) findViewById(R.id.textView1);
  tv.setText(location.getLongitude()+"  "+location.getLatitude());
  }
  
  public void onStatusChanged(String provider, int status, Bundle extras) {}
  
  public void onProviderEnabled(String provider) {}
  
  public void onProviderDisabled(String provider) {}
  };
  
  //Register the listener with the Location Manager to receive location updates
  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,   locationListener);
  }
  }
  </code></pre>
  
  <p>Another method that I have tried and also didn't work is below: </p>
  
  <pre><code>  import android.app.Activity;
    import android.content.Context;
    import android.location.Criteria;
    import android.location.Location;
    import android.location.LocationListener;
    import android.location.LocationManager;
    import android.os.Bundle;
    import android.util.Log;
    import android.widget.TextView;
    import android.widget.Toast;
  
   public class MainActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  /* Use the LocationManager class to obtain GPS locations */
  LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  LocationListener mlocListener = new MyLocationListener();
  mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
  
  }
  
  /* Class My Location Listener */
  public class MyLocationListener implements LocationListener
  {
      @Override
      public void onLocationChanged(Location loc)
      {
          loc.getLatitude();
          loc.getLongitude();
  
          String Text = "My current location is: " +
                        "Latitude = " + loc.getLatitude() +
                        "Longitude = " + loc.getLongitude();
  
          Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onProviderDisabled(String provider)
      {
          Toast.makeText( getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT ).show();
      }
  
      @Override
      public void onProviderEnabled(String provider)
      {
          Toast.makeText( getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onStatusChanged(String provider, int status, Bundle extras)
      {
      }
  
  }/* End of Class MyLocationListener */
  }
  </code></pre>
  
  <p>The permisssions set for both are:</p>
  
  <pre><code>    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES"&gt;&lt;/uses-permission&gt;
  </code></pre>