Stretched Screen on mobile devices which do not have 16:9 ratio

Hey everyone. I am developing a game for android devices, and I use

Screen.SetResolution(1280, 720, true);

to set the resolution of the game.
However in devices that are not in a 16:9 ratio. It appears to stretch either horizontally and vertically.UI also get stretched. I use

        cam.aspect = Screen.width/Screen.height;

to set the aspect ratio. What do I do so it doesn’t stretch but want the game to fill the whole non-16:9 screen

Some more information is needed to help answer your question.

Why are you using Screen.SetResolution?

Is the screen being used portrait or landscape (because cameras are set on the vertical axis)?

Are you using a Perspective or Orthographic camera (they work differently)?

Im using screen.setresolution as a resolution setting thing. Like to lower or increase the resoluyion

Why are you doing that? It is hard to give an answer without that.