https://paste.ubuntu.com/24513203/
---------------------
Wifiac();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
Log.e("asdasdas", "chek ilk if");
} else {
NetworkProvider();
Log.e("CurrenCalisti", "gpsCofig");
}
@Overridepublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case 1:
// If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
NetworkProvider();
} else {
// permission denied
}
break;
}
}
---------------
private void NetworkProvider(){
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 100, 0, new LocationListener() {
@Override public void onLocationChanged(Location location) {
String currentLat = String.valueOf(location.getLatitude());
String currentLot = String.valueOf(location.getLongitude());
TabbedActivity._curLat =location.getLatitude();
TabbedActivity._curLng =location.getLongitude();
Log.e("Curren= ", currentLat + "," + currentLot);
}
@Override public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override public void onProviderEnabled(String s) {
}
@Override public void onProviderDisabled(String s) {
}
});
}
---------------
public void Wifiac(){
WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
boolean enabled = wifiManager.setWifiEnabled(true);
Log.e("wifiDurum", String.valueOf(enabled));
}
-----------------
Hiç yorum yok:
Yorum Gönder