Getter Setter - Null pointer Exception Android

view story

http://stackoverflow.com – I am setting the location values using getter setter in one class and using it in another activity class where i am getting null pointer exception. I am using singleton pattern for the same. Here is my code: CurrentLocationResult locationResult; public boolean getCurrentLocation(Context context){ if(locationManager==null){ locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); } locationResult = CurrentLocationResult.getSingletonObject(); try { gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch (Exception e) { (HowTos)