AOKP/packages_apps_ROMControl — comment on commit 82a49e0d42175947f42b4575ae9aac88d5089c49
File:  line 0
By trajano:

I was just thinking the reason you may have a null is because somewhere along the line you may be trying to connect to the weather service but have little or no internet.

This is the code snippet I have to make sure that there is connectivity (i.e. not on airplane mode) in my code
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final boolean backgroundEnabled = cm.getBackgroundDataSetting();
if (!backgroundEnabled) {
return;
}

https://github.com/trajano/GasPrices/blob/master/src/main/java/net/trajano/gasprices/GasPricesUpdateService.java