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