title: Current Latitude And Longitude Not Shown
body: <p>I am making an app in Android Studio where the user can save their current latitude and longitude in Firebase. I am using this code:</p>
  
  <pre><code>public class SaveLocationActivity extends AppCompatActivity implements LocationListener {
  
  TextView saveLatitude, saveLongitude;
  Button saveLocationBtn;
  FirebaseDatabase firebaseDatabase;
  DatabaseReference databaseReference;
  LocationManager locationManager;
  Double latitude,longitude;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_save_location);
  
      firebaseDatabase = FirebaseDatabase.getInstance();
      databaseReference = firebaseDatabase.getReference().child("User");
  
      saveLatitude = findViewById(R.id.saveLatitude);
      saveLongitude = findViewById(R.id.saveLongitude);
      saveLocationBtn = findViewById(R.id.saveLocationBtn);
  
      if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  
          ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION}, 101);
  
      }
  
      saveLocationBtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              getLocation();
          }
      });
  
  }
  
  public void getLocation() {
      try {
          locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 5, SaveLocationActivity.this);
      }
      catch (SecurityException e)
      {
          e.printStackTrace();
      }
  }
  @Override
  public void onLocationChanged(Location location)
  {
      latitude=location.getLatitude();
      String latStr=latitude.toString();
  
      longitude=location.getLongitude();
      String longStr=longitude.toString();
  
      saveLatitude.setText(latStr);
      saveLongitude.setText(longStr);
  
      databaseReference.push().setValue("Latitude : "+latStr);
      databaseReference.push().setValue("Longitude : "+longStr);
  
      Toast.makeText(SaveLocationActivity.this, "Location Saved !!!", Toast.LENGTH_LONG).show();
      Intent i=new Intent(SaveLocationActivity.this,DisplayProfile.class);
      i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
      startActivity(i);
      SaveLocationActivity.this.finish();
  }
  
  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) {
  
  }
  
  @Override
  public void onProviderEnabled(String provider) {
  
  }
  
  @Override
  public void onProviderDisabled(String provider) {
      Toast.makeText(SaveLocationActivity.this, "Please Enable GPS and Internet !!!", Toast.LENGTH_SHORT).show();
  
  }
  }
  </code></pre>
  
  <p>Now whenever I am running this app in my phone it shows the Toast message "Please Enable GPS and Internet !!!" inspite of the fact that I have my Location on in phone and also have a working internet connection. I am actually using my home wifi for internet connection. If anyone find any mistake in my code please let me know also please suggest me a possible solution.</p>