私のAndroid携帯電話の現在地を取得して地図上に表示しようとしています。別のデバイスで動作しますが、デバイスのGPSがオンになっている場合、デバイスにはワールドマップのみが表示されます。コードはAndroidが現在のデバイスの場所を取得できません
if(locationManagerCheck .isLocationServiceAvailable()){
if (googleMap == null) {
try {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
e.getMessage(), Toast.LENGTH_SHORT)
.show();
}
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Harita oluşturulamadı", Toast.LENGTH_SHORT)
.show();
} else {
googleMap.setMyLocationEnabled(true);
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude, longitude);
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
googleMap.setOnMyLocationChangeListener(null);
// MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Konumunuz");
//marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
//googleMap.addMarker(marker);
}
});
}}
}else{
locationManagerCheck .createLocationServiceError(Anasayfa.this);
}
こちらをご覧ください。
携帯電話のOSのバージョンは? 6.0以上? –
私の電話は6.0です。私は4.4で試してみましたが、それは場所を見つけることができますが、私の電話では –
のAndroid 6用の地図しか表示されません。 –