Simple Analysis of Android phone answering Process

Source: Internet
Author: User

A new call is listened by callnotifier. The callnotifier class inherits from handler. In callnotifier. Java, the message representing the new vertex is phone_new_ringing_connection.

Mphone. registerfornewringingconnection (this, phone_new_ring_connection, null );

Of course, you have to register this signal. When a new call arrives, callnotifier receives the new number and submits it to onnewringingconnection (asyncresult) msg. OBJ) for processing.

In onnewringingconnection,

Boolean provisioned = settings. Secure. getint (mphone. getcontext (). getcontentresolver (),
Settings. Secure. device_provisioned, 0 )! = 0;
Check whether a rejected call is set. If yes, stop the call directly. Then, set the audio to the bell state and query the incoming call information through startincomingcallquery (connection C.

In startincomingcallquery (), first determine whether the query can be performed. If not, directly start the caller interface. Otherwise, continue to query the Caller information, such as the corresponding ringtone. After the query, start the call interface, that is, call displaycallscreen ();

 

After the call interface is started, the call control is completely transferred to incallscreen. java, but till now, the phone is still not connected, but a call is notified. That is, callnotifier. the task completed by Java is named exactly the same as its name, but plays the role of notify. On the incoming call interface, incallscreen. Java listens to the user's key event. If you press the access key, you will receive the call. If you press the connection key, you will end the call.

 

When you press the access key, callnotifier receives a phone_state_changed signal. If you press the host key, it receives a phone_state_diconnect. If you answer the call, set the audio status to the phone status and stop the ring, place a phone answer icon on the screen. At the same time, incallscreen also receives a new number, which updates the call interface, such as lighting the screen and making the menu disappear. However, if you stop a call, update the call record and stop the bell.

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.