It will mostly depend on how distant and how accurately you want to measure distance. The link from
@Pendrush (more specifically
Depth Maps ) is quite limited in both. Recommended working distances of 0.5m-5.0m. And, Despite milimeter reporting, accuracy explanation is vague and hardware dependant.
Alternatively you need to know some facts (or estimations) and use trigonometry. If you know a dimension of the object you want to distance, it's height or width, then you can use the camera and devices angle sensors to record the top/bottom (or left/right) angles from the camera and with the known height/width trigonometry does the rest. Again accuracy will be limited by the device angle sensors and steadiness of the device but within those constraints, far greater distances can be measured.