The vibration function can be further used to set system parameters and be implemented using preference.
Package com. Android. Phone;
Import com. Android. Internal. telephony. Phone;
Import com. Android. Internal. telephony. phonebase;
Import com. Android. Internal. telephony. GSM. suppservicenotification;
Import com. Android. Phone. cdmadisplayinfo;
Import com. Android. Phone. notificationmgr;
Import com. Android. Phone. callnotifier. incalltoneplayer;
Import Android. OS. asyncresult;
Import Android. OS. message;
Import Android. util. log;
// Incoming call entry
Public class callnotifier extends handler implements callerinfoasyncquery. onquerycompletelistener {
// Save the previous status
Private call. State mpreviouscallstate;
Private void onnewringconnection (asyncresult R ){
}
// Process the call status message
@ Override
Public void handlemessage (Message MSG ){
Switch (msg. What ){
// Other
Case phone_state_changed:
Onphonestatechanged (asyncresult) msg. OBJ );
Break;
// Other
}
}
// When the call status changes
Private void onphonestatechanged (asyncresult R ){
// Other
// Determine the call status.
If (mphone. getforegroundcall (). getstate () = call. state. Active)
& (Mpreviouscallstate = call. state. Dialing) | (mpreviouscallstate = call. state. Alerting ))){
Vibrator VBR = (vibrator) mphone. getcontext (). getsystemservice (context. vibrator_service );
VBR. vibrate (200 );
}
Mpreviouscallstate = mphone. getforegroundcall (). getstate ();
}
}