For accurate magnetometer compass readings, hold your mobile device completely flat, parallel to the floor.
If the direction seems wrong, wave your phone in a horizontal figure-8 motion a few times to re-calibrate internal compass sensors.
Keep your phone away from metal tables, keychains, electronic hardware, or magnetic cases which skew sensors.
If sensors are missing (like on desktops/laptops), check the interactive map and align visually along the red dashed line pointing to Makkah.