I know that in the image acquisition stage, after obtaining the analog image from the sensors, it is sampled and quantized. How the Nyquist sampling is achieved? The sampling frequency must be at least twice the highest spatial frequency (measured by pixels per inch) in the image. I know that the pixel per inch (ppi) is related to screen or printers, then how will the spatial frequency (measured in pixels per inch) be calculated in order to achieve the Nyquist sampling condition?
The digital image acquisition sensor (CMOS, CCD etc) is typically defined with a physical area of H x W (usually expressed in diagonal length in mm) and number of photo-sensitive elements; the pixels. PPI is not a part of sensor specifications for cameras, (but it can be for scanners yet you're dealing with smart phone cameras).
The Nyquist rate of an image sensor is determined by the lens resolution limit. The optical image that's formed on the sensor surface shall not achieve a resolution higher than the pixel spacing can resolve. Otherwise, a distortion known as aliasing will happen.
You don't need to know the PPI value of a senor to determine its Nyquist rate.
Note that with different digital image sizes you will always have unaliased images; this shall be guaranteed by the camera design and not the user.
However, you can apparently compute the PPI value of the sensor by dividing its number of horizontal pixels to its horizontal sensor length which is mostly a useless metric by itself.
How the Nyquist sampling is achieved?
Generally it's done by the person running the camera being careful about what they're photographing and/or filming. It's well-known in video circles that you don't let someone with a finely striped shirt onto the set because you'll get all sorts of horrible Moire patterns in the finished video.
At work I have occasion to take a picture of a screen that's showing misbehaving software. In that case if I really want to take a good picture I'll put my phone in manual focus and purposely defocus the image a bit, to avoid the Moire patterns.