Simple Analysis of andoird dialing process

Source: Internet
Author: User

Android dialing is divided into two types: one is to enter a number through the dial, and then press the call key to dial out, and the other is to call out through a contact or call record.

 

Method 1: placecall () in twelvekeydialer. Java ()

Void placecall (){
Final string number = mdigits. gettext (). tostring ();
If (number = NULL |! Textutils. isgraphic (number )){
// There is no number entered.
Playtone (tonegenerator. tone_prop_nack );
Return;
}
Intent intent = new intent (intent. action_call_privileged,
Uri. fromparts ("tel", number, null ));
Intent. setflags (intent. flag_activity_new_task );
Startactivity (intent );
Mdigits. gettext (). Clear ();
Finish ();
}

Set one action_call_privileged to automatically match with outgoingcallbroadcaster.

If (intent. action_call_privileged.equals (Action )){
Action = emergencynumber
? Intent. action_call_emergency
: Intent. action_call;
Intent. setaction (action );
}

Identify whether the number is an emergency number. If it is an emergency number, initiate an incallscreen activity immediately. If it is not, send a broadcast and forward a dial intent,

Intent broadcastintent = new intent (intent. action_new_outgoing_call );
If (number! = NULL) broadcastintent. putextra (intent. extra_phone_number, number );
Broadcastintent. putextra (extra_already_called, callnow );
Broadcastintent. putextra (extra_original_uri, intent. getdata (). tostring ());
If (logv) log. V (TAG, "broadcasting intent" + broadcastintent + ".");
Sendorderedbroadcast (broadcastintent, permission, null, null,
Activity. result_ OK, number, null );

However, after outgoingreceiver receives the broadcast, it starts an incallscreen

Intent newintent = new intent (intent. action_call, Uri );
Newintent. putextra (intent. extra_phone_number, number );
Newintent. setclass (context, incallscreen. Class );
Newintent. addflags (intent. flag_activity_new_task );

Context. startactivity (newintent );

This completes the dialing process.

 

 

In the historical call history interface

Protected void onlistitemclick (listview L, view V, int position, long ID ){
Static final int column_index_number = 4; | intent = new intent (this, calldetailactivity. Class );
| Intent. setdata (contenturis. withappendedid (calllog. CILS. content_uri, ID ));
@ Override | startactivity (intent );
Protected void oncreate (bundle icicle) {|}
Start a calldetailactivity. On the calldetailactivity interface, if the current phone number is idle, send an action_call_privileged directly to outgoingcallbroadcaster.

Telephonymanager TM = (telephonymanager) |
Getsystemservice (context. telephony_service); | int calltype = cursor. getint (call_type_column_index );
If (TM. getcallstate () = telephonymanager. call_state_idle) {| if (! Number. startswith ("+ ")&&
Intent callintent = new intent (intent. action_call_privileged, | (calltype = CILS. incoming_type
Uri. fromparts ("tel", mnumber, null); | calltype = CILS. missed_type )){
Startactivity (callintent );

 

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.