The Application automatically detects the driving mode and allows you to contact for up to three phone numbers of emergency in case of accident.
The three numbers will be contacted by sending a text message as ( custom emergency message) with the geographical coordinates of the accident site.
I have divided this project in to three phases ,
i) Detection of driving Mode:-(Intent Service)
I'm using Google Activity Recognition API to detect the driving Mode and logic behind it is , if ( DetectedActivityType="IN_VEHICLE" && Confidence > "90") then i will consider it as driving Mode
ii) Detect Accident:-(Service)
In this phase i want to detect impact at the moment of accident with help of accelerometer in a mobile.
Please refer the link below
At the moment when i detect the driving mode , i'll start taking linear_acceleration readings as ( x-axis = Sensor.event, y-axis = Sensor.event ,z-axis = Sensor.event ) and i can have the values of gravity as well (x-axis = Sensor.event, y-axis = Sensor.event ,z-axis = Sensor.event ) and net gravity is constant, but corresponding x,y,z values of gravity changes as if you tilt the phone in different direction.
Generally, standard gravity value is around = 9.8 m/s2 and its direction is always towards ground.
we have x,y,z values of gravity. so,we can calculate angle between x-axis to standard gravity,similarly we can calculate for y,z axis. say(alpha,beta & gamma)
since, x,y,z axis is fixed to the mobile, so we can calculate linear_acceleration towards ground say (a_g) with help of a (alpha,beta & gamma).
Now, i'll take threshold value as 3g ( i,e 3 * 9.8)
if(change_in_net_linear_acceleration >= 20 )
if (a_g >3g)
// wait for ten seconds
// checking whether the person is moving or not , if not moving consider he/she is unconscious
if(DetectActivityType=="STILL" && confidence=="90")
iii) Send Message to concerned people ;-(Service)
At the moment when i detect the impact , I will invoke this service and send text message to the concerned people with geographical coordinates of accident site with the help of GPS.
boolean x = detect_Impact();
I have successfully written code for the 1st and 3rd phase , but in the second phase i'm not able to get (alpha, beta and gamma) values correctly . My Query is whether the logic can be implementable or not , if yes, then please kindly help me out to calculate the values of alpha , beta ,gamma values.