Android: By default, your Android device's proximity sensor should turn your display off when you bring your phone up to your ear to take a call, and turn it back on when you pull it away from your ear, but not all phones do the job well, and even fewer extend that feature to when you put your phone face-down on a table or in your pocket. Smart Screen Off is an Android app by XDA forum member Ddeleted which does just that.

Smart Screen Off is free and app works as advertised. if you wish your phone's display would turn off as soon as you put it in your pocket, or put it down on a table, without having to rely on the screen timer to do the job for you, this app can help. Keep in mind that it just cuts power to the screen—it doesn't lock your device. A number of people in the forum note that the app is especially useful for those with flip-style cases, or if you're exercising while listening to music and don't want to unlock your phone every time you want to change songs. Smart Screen Off supports any version of Android, but it requires your phone have a proximity sensor to work (it probably already does.) You can snag it at the Android Market.

Smart Screen Off | Android App Market via XDA-developers forum