I don't normally like to lock my phone as I find it annoying.
Is it possible to enable the lock or some kind of encryption on the phone in an emergency, for example by holding down a number of the hardware buttons?
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
Opposing ce4, I see a possibility using e.g. Tasker. In case you don't know it: Tasker is the most complex automation tool available on Android. You connect "events" (as e.g. phone rings, incoming SMS, a given time (clock), a location, ...) with "tasks" (actions to be taken, as e.g. switching mobile data on/off, enabling/disabling airplane mode, adjust volume, and much more) to so-called "profiles".
So here comes an example profile for your problem:
So with that profile, if you hold down the camera key and shake your device, the configured keyguard (pattern lock, pin, password) will be activated. Obviously you need the opposite action as well: Use the above again with a different "shake pattern" and, of course, "Keyguard Off" in the task.
So initially, you configure your pattern/pin/password to be set on, as usual on Android (so the system knows which one to use). After that, use your configured hold-shake-pattern to activate and deactivate it.
Pretty simple. Though I didn't test it -- but I like that idea, so I certainly will test it soon myself :)
It's probably not possible with stock firmware.
You definitely have to have encryption enabled beforehand, as switching it on takes around an hour and cannot be intercepted. And encryption forces you to have a secured lock-screen normally (stock firmwares).
CyanogenMod7/9/10 has a unique Profiles feature; I was able to set up one with a disabled lock-screen. You can switch between profiles rather quickly (long-pressing the power-button brings up the power menu where one can switch profiles).
CyanogenMod users can read more here:
What are Cyanogenmod's profiles good for?
Certificate Install without mandatory PIN lockscreen
Android “fake having a locked phone” - Galaxy SII