title: not get the value of latitude and longitude in google map in android
body: <p>I am using the GoogleMap. and It is display current position currectly but latitude and longitude are display 0.0 in system.out.println in displayMap() method. My question is why not display current latitude and longitude?</p>
  
  <p>I send you my code. please check my code and suggest me that how to fetch value of current latitude and current longitude?
  Button btnSubmit = null;</p>
  
  <pre><code>/** Use for Google Map */
  
  
  private GoogleMap googleMap = null;
      private SupportMapFragment supportMapFragment = null;
      public double latitude=0, longitude=0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.splash_screen);
          btnSubmit = (Button) findViewById(R.id.btnSubmit);
          btnSubmit.setOnClickListener(this);
  
          try {
              // Loading map
              initializeMap();
  
          } catch (Exception e) {
              e.printStackTrace();
          }
  }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
      }
  
      /** Default Map is Initialize */
      @SuppressLint("NewApi")
      private void initializeMap() {
          if (googleMap == null) {
              // googleMap = ((MapFragment) getFragmentManager().findFragmentById(
              // R.id.map)).getMap();
  
              supportMapFragment = ((SupportMapFragment) getSupportFragmentManager()
                      .findFragmentById(R.id.map));
              googleMap = supportMapFragment.getMap();
  
              if (googleMap != null) {
                  displayMap();
              }
          }
      }
  
      /** Display The Current Location on Map */
      private void displayMap() {
          // Enable MyLocation Layer of Google Map
                  googleMap.setMyLocationEnabled(true);
  
                  // Get LocationManager object from System Service LOCATION_SERVICE
                  LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
  
                  // Create a criteria Object to retrieve provider
                  Criteria criteria = new Criteria();
  
                  // Get the name of best provider
                  String provider = locationManager.getBestProvider(criteria, true);
  
                  // Get Current Location
                  Location myLocation = locationManager.getLastKnownLocation(provider);
  
                  // set Map Type
                  googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
  
                  // Get latitude of Current Location
                  latitude = myLocation.getLatitude();
                  System.out.println("latitude====="+latitude);
  
                  // Get longitude of Current Location
                  longitude = myLocation.getLongitude();
                  System.out.println("longitude====="+longitude);
                  // Create a LatLng object for the current location
                  LatLng latLng = new LatLng(latitude, longitude);
  
                  // Show the current location in Google Map
                  googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
  
                  // Zoom in Google map
                  googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
                  googleMap.addMarker(new MarkerOptions().position(
                          new LatLng(latitude, longitude)).title("You R Here..."));
  
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          initializeMap();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public void onClick(View view) {
          switch (view.getId()) {
          case R.id.btnSubmit:
              Intent intent = new Intent(getBaseContext(), RegisterActivity.class);
              intent.putExtra("latitude", latitude);
              intent.putExtra("longitude", longitude);
              startActivity(intent);
              break;
  
          default:
              break;
          }
      }
  
  }
  </code></pre>
  
  <p>My xml file is,</p>
  
  <pre><code> &lt;fragment
          android:id="@+id/map"
          android:name="com.google.android.gms.maps.SupportMapFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  </code></pre>