How to get the location in OpenMRS

When you log in openmrs, you see location such as Inpatient Ward or Pharmacy or Outpatient Clinic etc. How i can get this location ? Context.getUserContext().getLocation(), Context.getUserContext().getLocationId() does not work.

This looks like a duplicate for How to get the location in OpenMRS