wie man den aktuellen Standort in Google Map Android abruft

Eigentlich ist mein Problem, dass ich nicht den aktuellen Breiten- und Längengrad des Standorts erhalte. Ich habe so viele Möglichkeiten ausprobiert. Ich weiß, dass diese Frage bereits in SO gestellt wurde. Ich habe auch versucht, diese Antworten zu beantworten.

    if (googleMap == null) {
        googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                R.id.map)).getMap();

        // check if map is created successfully or not
        if (googleMap == null) {
            Toast.makeText(getApplicationContext(),
                    "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                    .show();
        }
    }
    googleMap.setMyLocationEnabled(true);
    Location myLocation = googleMap.getMyLocation();  //Nullpointer exception.........
    LatLng myLatLng = new LatLng(myLocation.getLatitude(),
            myLocation.getLongitude());

    CameraPosition myPosition = new CameraPosition.Builder()
            .target(myLatLng).zoom(17).bearing(90).tilt(30).build();
    googleMap.animateCamera(
        CameraUpdateFactory.newCameraPosition(myPosition));

Antworten auf die Frage(15)

Ihre Antwort auf die Frage