Soru & Cevap

Android Harita Location Manager Hatası ...

12.12.2015 - 03:24

Merhaba Arkadaşlar,

harita üzerinde konum bulma üzerine çaışıyorum. ancak requestLocationUpdates (LocationManager.GPS_PROVIDER, , , ) kodunda sürekli hata alıyorum.

bütün izinlerimide verdim. Bu konuda yardımcı olabilirmisiniz?

 

public class MapsActivity extends FragmentActivity {
    public boolean isGPSEnabled = false;
    public boolean isNetworkEnabled = false;
    private static final long MINIMUM_TIME_BETWEEN_UPDATES = 10000;
    private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10000;  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.

        LocationManager konumYönetici = (LocationManager) this.getSystemService(LOCATION_SERVICE);
        isGPSEnabled = konumYönetici.isProviderEnabled(LocationManager.GPS_PROVIDER);
        isNetworkEnabled = konumYönetici.isProviderEnabled(LocationManager.NETWORK_PROVIDER);


        String locationProvider = LocationManager.GPS_PROVIDER;

            LocationListener konumDinle = new LocationListener() {

            @Override
            public void onLocationChanged(Location location) {
                Toast.makeText(getBaseContext(),
                        "Latitude: " + location.getLatitude() +
                                " Longitude: " + location.getLongitude(),
                        Toast.LENGTH_SHORT).show();}   @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {}
            @Override
            public void onProviderEnabled(String provider) {}
            @Override
            public void onProviderDisabled(String provider) {}};
   konumYönetici.requestLocationUpdates(LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, 0, konumDinle);

aldığım hata  

            Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException` less... (Ctrl+F1)

This inspection looks at Android API calls and ensures that the correct type of resource is passed to an int-parameter expecting resources of a given type; it checks that APIs which expect an RGB color integer are passed actual colors rather than color resources; it checks that APIs which require a certain permission have the permission declared in the manifest; it checks that parameters expected to fall within a given range actually do; it checks that results of certain method calls are looked at by the caller, and so on.     

25 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user chatinrock
chatinrock
21.04.2016 - 11:01

Android Sdk (API 23) kullanmalısınız.Eski versiyonlarda çalışmamaktadır.