I take it that you want a script for Unity, considering the icon of the thread.
I wrote a script that handle this. My method is to resize the camera viewport. Not sure if it's the best way to do it, so any suggestion would be greatly appreciated. I made this mainly for my 2d games, so it might not work with 3d.http://pastebin.com/GDZ8wNZH
How to use
1. Go into the script and change the global variables to your appropriate game resolution.
2. Global Offset variables are for positioning the whole screen in case the device resolution doesn't fit the screen and a letter box is required.
3. Attach the script to cameras that will render the game on the screen.
4. Adjust camera's width, height and offsetting variables. If this camera will show the whole screen, then the width and the height should be the same as the game resolution, and all the offset values should be zero.
Trying to make it taking an effect even in the editor mode, but I think I fail. So you have to press play to see its effect.