Better Keyguard is actually nothing more than a Tasker profile exported as an Android APK. It is programmed to enable the proximity sensor for 1 second, every time the display is switched on. If the sensor is not covered in that particular moment, nothing will happen, but if it is, the screen will be turned off right away, so no accidental pocket dialling can occur.
We tried it on our Motorola Moto G smartphone and it worked just fine. There are a few things you need to do for the app to work, though: first, you’d need to give it admin rights (go into Settings -> Security -> Device Administrators, and mark Better Keyguard).
On some smartphones, inside the app, you’d need to check “Try to disable built in” option. And finally, on some smartphones, the app won’t work with a pattern lock – you need to switch to no lock at all (go to Settings -> Security -> Screen Lock -> select None).