title: Swtich between GPS and Network?
body: <p>This code works perfectly for GPS:</p>
  
  <pre><code>public class GetLocation extends Activity implements LocationListener {
  
      LocationManager lm;
      TextView tv;  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_get_mission);
  
  
       // Acquire a reference to the system Location Manager
          tv= (TextView)findViewById(R.id.locationOutput);
  
          lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 1, this);
  
  
  
      }
      public void onLocationChanged(Location arg0) {
          String lat = String.valueOf(arg0.getLatitude());
          String lon = String.valueOf(arg0.getLongitude());
          Log.e("GPS", "location changed: lat="+lat+", lon="+lon);
          tv.setText("lat="+lat+", lon="+lon);
      }
      public void onProviderDisabled(String arg0) {
          Log.e("GPS", "provider disabled " + arg0);
      }
      public void onProviderEnabled(String arg0) {
          Log.e("GPS", "provider enabled " + arg0);
      }
      public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
          Log.e("GPS", "status changed to " + arg0 + " [" + arg1 + "]");
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_get_mission, menu);
          return true;
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case android.R.id.home:
                  NavUtils.navigateUpFromSameTask(this);
                  return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
  }
  </code></pre>
  
  <p>However I want to get the location from Network not GPS. So I change:</p>
  
  <pre><code>lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 1, this);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
  </code></pre>
  
  <p>Then I get nothing. Is this down to an error in the code, or is it that the location doesn't change as frequently as it does with GPS therefore onLocationChange is never called? If I want to see the location at this time without a change should I use <code>.getLastKnownLocation</code> if so where can I call this so that it will update when the app starts? </p>