Android phone calls vibrate

Source: Internet
Author: User

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 ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.