Kişisel Sayfaları
İlgi Alanları
İş Tecrubesi
Eğitim Geçmişi
Dil Becerileri
Son Forum Aktiviteleri
2Android Harita Location Manager Hatası
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.
Buton ile GPS açma kapama
basla.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
});
butona basıldığı zaman GPS açılıyor.