How the direction is found
The Qibla is the direction of the Kaaba in Makkah, at about 21.4225° N, 39.8262° E. Prayer Pal takes your location and calculates the starting direction of the shortest path across the Earth's surface from you to the Kaaba — the great-circle route.
Your phone's compass then turns the needle as you turn, so you can face it. The calculation happens on the phone itself, which is why it keeps working offline once your location is known.
When the compass asks to calibrate
A phone's compass can drift near metal and electronics. When its reading is unreliable, the app shows Calibration Needed and asks you to move your device in a figure-8 pattern. Hold the phone flat, away from magnets, speakers and metal surfaces, then turn slowly until the needle settles.
On iPhone, the first time you open Qibla the app asks you to enable compass access; tap Enable Compass to allow it.