Is there a way to send an emergency text and/or email by holding down either of the volume buttons? A friend of mine recently developed a medical condition that causes sudden shortness of breath, and in one instance, caused her to pass out. In that instance, she said she lost her vision first, so she couldn't make a phone call to anyone.

I found some apps that send emergency messages by pressing a button in the lock screen, but it may be hard to do so without being able to see (though certainly better than trying to punch in a phone number). I was wondering if there was a way to send messages by holding down a physical button for, say, 5 seconds. (Of course, the contacts/message would be preconfigured/preset.) I'm not sure if it's even possible for an app to "hijack" a button's functionality in such a way.
tl;dr: I wasn't aware of any such apps and so I've actually written an application that can do this for a university project; the user holds the volume down button for x seconds (default is 3) and a preconfigured emergency message is sent to their chosen contact(s). There are a few problems with getting this functionality however (see below). I haven't made the app available anywhere but could put a version up on the Play Store over the next few days. Will edit this when I do.



The problem I found is that it doesn't work in all possible states the phone could be in, meaning your friend might be trying to use it but will forget to put it in a correct state if they're in a panic. Here's the results of the testing I did, a pass means the emergency SMS was sent: 




  One test wasn’t applicable because if the screen is off pressing the
  volume button will turn it back on giving us the first test state. 
  
  For the state where the screen was on but phone was locked, the evidence
  gathering could be activated but only by pressing the volume button
  repeatedly for the required amount of time. 
  
  The reason the activation doesn’t work as intended is because Android
  only receives one button press when the volume button is held while the
  screen is locked and so only passes one press to the application. If the volume button is repeatedly pressed then
  the application is ‘tricked’ into thinking the button is being held
  constantly because the app checks if the button is being held once a
  second but the button only needs to have been held once in the last
  second for it to count.


A positive point about the volume button method is that it uses almost no battery, there isn't any monitoring or polling of the volume button's state.



If you were willing to consider other activation methods I also added the ability to tilt the phone and have it activate the emergency SMS, I found this worked in a lot more states:



I believe it would also be possible to get the Tasker application to do this tilting activation but I don't own it and haven't tried it.