Sending an automated SMS before switching off the phone Can I send an automated SMS to any specific number by an application/service (which I set ON), if phone gets switched off before closing that service or application?
Also can I do the same if phone breaks down in an accident or if I do specific action on phone, such as "Tap the screen 3 times while phone's screen is locked", or "shake the phone 3 times while it is locked"? 

Thanks.
Tasker should do the first things you asked about, but I doubt you'll find anything that can recognize "Tap the screen 3 times while phone's screen is locked" or "shake the phone 3 times while it is locked", short of writing a custom app.

https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&amp;hl=en

Tasker is a great app in general that you really should check out since it sounds like you want to do a lot of automation type stuff.