When we use HTC's gxx, we will find that it has a function of vibrating prompt after it is connected. Although it is not a big function, it is more convenient to use, for example, when the call process occurs, you can place it on the table and wait for the vibration. This means that the phone is connected, and then the phone gets up and talks, so you can avoid waiting for the other party in your ear. The specific implementation is as follows. Of course, the implementation method may be different from it, but the effect is the same.
Because we are developed based on source code, we will only discuss how to add this function to phoneapp. We will not discuss independent modules or SDK-based development. Note: Modify the callpolicy. Java file in the phoneapp module.
1. Declare variables related to vibrartor:
// Call active route y vibrate <br/> private vibrator mvibrator; </P> <p> // default vibrate time <br/> Private Static final int vibrate_length = 100; <br/> private Boolean malreadyvibrate = true;
2. Create Vibrator In the constructor:
Mvibrator = new vibrator ();
3. Add the following code segment to the end of onphonestatechanged, that is, the GSM Branch (only supports GSM call:
If (callstate = call. state. disconnecting) {<br/> malreadyvibrate = true; <br/>} else if (malreadyvibrate & <br/> callstate = call. state. active) {<br/> // vibrate policy <br/> mvibrator. vibrate (vibrate_length); <br/> malreadyvibrate = false; <br/>}
Note: malreadyvibrate is mainly used to prevent repeated vibration. OK. Test it ~