use of com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator in project Alarmio by TheAndroidMaster.
the class Alarmio method getSunsetCalculator.
@Nullable
private SunriseSunsetCalculator getSunsetCalculator() {
if (sunsetCalculator == null && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
try {
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
android.location.Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(new Criteria(), false));
sunsetCalculator = new SunriseSunsetCalculator(new Location(location.getLatitude(), location.getLongitude()), TimeZone.getDefault().getID());
} catch (NullPointerException ignored) {
}
}
return sunsetCalculator;
}
Aggregations