Compass functionality in phones and tablets is enabled by something a bit more sophisticated \u2013 a sensor called a magnetometer, which is used to measure the strength and direction of magnetic fields. By analyzing Earth's magnetic field, the sensor allows a phone to determine its orientation pretty accurately.