I don't understand why the app closes:
java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLongitude()' on a null object reference
private void getWeatherInformation() {
compositeDisposable.add(mSevice.getWeatherByLatLhg(String.valueOf(Common.current_location),
String.valueOf(Common.current_location.getLongitude()),
Common.APP_ID,
"metric")
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<WeatherResponse>() {
@Override
public void accept(WeatherResponse weatherResponse) throws Exception {
Picasso.get().load(new StringBuilder("https://openweathermap.org/img/wn/")
.append(weatherResponse.getWeather().get(0).getIcon()).append(".png").toString()).into(imageWeather);
cityName.setText(weatherResponse.getName());
description.setText(new StringBuilder("Weather in ")
.append(weatherResponse.getName()).toString());
temperature.setText(new StringBuilder(String.valueOf(weatherResponse.getMain().getTemp()))
.append("°C"));
dateTime.setText(Common.convertUnixToDate(weatherResponse.getDt()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(getActivity(), ""+throwable.getMessage(), Toast.LENGTH_SHORT).show();
}
})
);