You need two things: the Qibla bearing for your location and a trustworthy reference for north. A phone with location access can calculate the bearing even when it has no working compass.
Start with coordinates, not a guess
Open the finder and allow location or enter coordinates manually. The displayed angle is clockwise from true north: east is 90°, south is 180°, and west is 270°. A north-up dial does not know which way you are holding your phone.
Use a map and a visible landmark
Set a map to north-up and locate your building. Identify a straight road or another feature you can see both on the map and outdoors. Use that feature to orient the map, then turn from north by the calculated bearing. Do not assume the top of a hotel floor plan is north.
Treat the sun and shadows as rough checks
The sun does not rise exactly east or set exactly west throughout the year. Its path depends on season and latitude. A vertical stick on level ground casts a shadow away from the sun; tracking the tip over time can help estimate east-west, but a short observation is not a precise north reference. Near the tropics, the midday sun can be north or south of you depending on the date.
Prefer a second independent check
Compare your estimate with a north-aligned map or a well-established local mosque direction. If weather, terrain, or uncertainty prevents a reliable direction, ask a local scholar about your particular circumstances rather than treating this navigation guide as a ruling.
Common questions
Can my phone calculate Qibla without a compass sensor?
Yes. Coordinates are enough to calculate the bearing. You still need a north reference to physically face that angle.
Is sunset always the Qibla direction?
No. Sunset direction varies, and the Qibla depends on where you are relative to Makkah.
Is the shadow method exact?
No. Ground slope, the observation interval, season and latitude affect a simple shadow estimate. Cross-check it.