Someone just sent me a mail and asked if we had any C# samples / source code for monitoring status of incoming and outgoing calls. It all really depends on what you want to do with these calls, are you just trying to get the status? or trying to capture the audio? they're two very different scenarios.
here's a list of System Properties that you can return using Microsoft.WindowsMobile.Status assembly. I guess the segment that you're most interested in is this:
Phone1xRttCoverageGets a value indicating whether the phone currently has 1xRTT coverage. PhoneActiveCallCountGets the number of active phone calls. PhoneActiveDataCallGets a value indicating whether the phone has an active cellular data connection. PhoneBlockedSimGets a value indicating whether the Subscriber Identity Module (SIM) is blocked. PhoneCallBarringGets a value indicating whether the call barring feature is enabled. PhoneCallCallingGets a value indicating whether the phone is currently attempting to connect an outgoing call. PhoneCallForwardingOnLine1Gets a value indicating whether call forwarding is enabled on line 1. PhoneCallForwardingOnLine2Gets a value indicating whether call forwarding is currently active on line 2. PhoneCallOnHoldGets a value indicating whether a phone call is currently on hold. PhoneCallTalkingGets a value indicating whether there is currently a phone call in the talking state. PhoneCellBroadcastGets the cell broadcast message PhoneConferenceCallGets a value indicating whether a conference call is currently in progress. PhoneGprsCoverageGets a value indicating whether the phone currently has GPRS coverage. PhoneHomeServiceGets a value indicating whether the phone is currently registered on its home network. PhoneIncomingCallGets a value indicating whether there is an incoming (ringing) call. PhoneIncomingCallerContactGets the Contact that matches the Caller ID. PhoneIncomingCallerContactPropertyIDGets the CEPROPID of the property that matches the Caller ID, for example, PIMPR_HOME_TELEPHONE_NUMBER. PhoneIncomingCallerContactPropertyNameGets the name of the property that matches the Caller ID, e.g. "h" for "Home Telephone". PhoneIncomingCallerNameGets the name of the person who is currently placing the incoming call. PhoneIncomingCallerNumberGets the incoming call's phone number (Caller ID). PhoneInvalidSimGets a value indicating whether the Subscriber Identity Module (SIM) is invalid. PhoneLastIncomingCallerContactGets the Contact that matches the last Caller ID. PhoneLastIncomingCallerContactPropertyIDGets the CEPROPID of the property that matches the last Caller ID, for example, PIMPR_HOME_TELEPHONE_NUMBER. PhoneLastIncomingCallerContactPropertyNameGets the name of the property that matches the last Caller ID, e.g. "h" for "Home Telephone". PhoneLastIncomingCallerNameGets the name of the last caller to place an incoming call. PhoneLastIncomingCallerNumberGets the last incoming call's phone number (Caller ID). PhoneLine1SelectedGets a value indicating whether line 1 is selected. PhoneLine2SelectedGets a value indicating whether line 2 is selected. PhoneMissedCallGets a value indicating whether there was a new missed call. PhoneMissedCallsGets the number of missed phone calls. PhoneMultiLineGets a value indicating whether the phone supports multiple lines. PhoneNoServiceGets a value indicating whether the phone is not currently connected to a network. PhoneNoSimGets a value indicating whether the Subscriber Identity Module (SIM) is installed in the mobile device. PhoneOperatorNameGets the name of the mobile operator (i.e., the mobile phone company, or carrier). PhoneProfileGets the non-localized name of the current sound profile. For example, "Normal", "Silent", "Car", "Headset", "Loud", "Meeting", or "Speakerphone". (Smartphone only) PhoneProfileNameGets the localized name of the current sound profile. (Smartphone only) PhoneRadioOffGets a value indicating whether the phone's radio is turned off. PhoneRadioPresentGets a value indicating whether the mobile device has a phone. PhoneRingerOffGets a value indicating whether the phone's ringer is off (i.e., if it rings and/or vibrates). PhoneRoamingGets a value indicating whether the phone is currently in roaming mode. PhoneSearchingForServiceGets a value indicating whether the phone is currently searching for service on a network. PhoneSignalStrengthGet the phone signal strength, expressed as a percentage of full strength. PhoneSimFullGets a value indicating whether the Subscriber Identity Module (SIM) memory is full. PhoneTalkingCallerContactGets the contact who is on the active phone call. PhoneTalkingCallerContactPropertyIDGets the CEPROPID of the property of the contact who is on the active phone call, for example, PIMPR_HOME_TELEPHONE_NUMBER. PhoneTalkingCallerContactPropertyNameGets the name of the property of the contact who is on the active phone call, e.g. "h" for "Home Telephone". PhoneTalkingCallerNameGets the name of the person you are talking to on the phone. This value is not set when you are talking on a conference call. PhoneTalkingCallerNumberGets the currently connected caller's phone number.
Phone1xRttCoverageGets a value indicating whether the phone currently has 1xRTT coverage.
PhoneActiveCallCountGets the number of active phone calls.
PhoneActiveDataCallGets a value indicating whether the phone has an active cellular data connection.
PhoneBlockedSimGets a value indicating whether the Subscriber Identity Module (SIM) is blocked.
PhoneCallBarringGets a value indicating whether the call barring feature is enabled.
PhoneCallCallingGets a value indicating whether the phone is currently attempting to connect an outgoing call.
PhoneCallForwardingOnLine1Gets a value indicating whether call forwarding is enabled on line 1.
PhoneCallForwardingOnLine2Gets a value indicating whether call forwarding is currently active on line 2.
PhoneCallOnHoldGets a value indicating whether a phone call is currently on hold.
PhoneCallTalkingGets a value indicating whether there is currently a phone call in the talking state.
PhoneCellBroadcastGets the cell broadcast message
PhoneConferenceCallGets a value indicating whether a conference call is currently in progress.
PhoneGprsCoverageGets a value indicating whether the phone currently has GPRS coverage.
PhoneHomeServiceGets a value indicating whether the phone is currently registered on its home network.
PhoneIncomingCallGets a value indicating whether there is an incoming (ringing) call.
PhoneIncomingCallerContactGets the Contact that matches the Caller ID.
PhoneIncomingCallerContactPropertyIDGets the CEPROPID of the property that matches the Caller ID, for example, PIMPR_HOME_TELEPHONE_NUMBER.
PhoneIncomingCallerContactPropertyNameGets the name of the property that matches the Caller ID, e.g. "h" for "Home Telephone".
PhoneIncomingCallerNameGets the name of the person who is currently placing the incoming call.
PhoneIncomingCallerNumberGets the incoming call's phone number (Caller ID).
PhoneInvalidSimGets a value indicating whether the Subscriber Identity Module (SIM) is invalid.
PhoneLastIncomingCallerContactGets the Contact that matches the last Caller ID.
PhoneLastIncomingCallerContactPropertyIDGets the CEPROPID of the property that matches the last Caller ID, for example, PIMPR_HOME_TELEPHONE_NUMBER.
PhoneLastIncomingCallerContactPropertyNameGets the name of the property that matches the last Caller ID, e.g. "h" for "Home Telephone".
PhoneLastIncomingCallerNameGets the name of the last caller to place an incoming call.
PhoneLastIncomingCallerNumberGets the last incoming call's phone number (Caller ID).
PhoneLine1SelectedGets a value indicating whether line 1 is selected.
PhoneLine2SelectedGets a value indicating whether line 2 is selected.
PhoneMissedCallGets a value indicating whether there was a new missed call.
PhoneMissedCallsGets the number of missed phone calls.
PhoneMultiLineGets a value indicating whether the phone supports multiple lines.
PhoneNoServiceGets a value indicating whether the phone is not currently connected to a network.
PhoneNoSimGets a value indicating whether the Subscriber Identity Module (SIM) is installed in the mobile device.
PhoneOperatorNameGets the name of the mobile operator (i.e., the mobile phone company, or carrier).
PhoneProfileGets the non-localized name of the current sound profile. For example, "Normal", "Silent", "Car", "Headset", "Loud", "Meeting", or "Speakerphone". (Smartphone only)
PhoneProfileNameGets the localized name of the current sound profile. (Smartphone only)
PhoneRadioOffGets a value indicating whether the phone's radio is turned off.
PhoneRadioPresentGets a value indicating whether the mobile device has a phone.
PhoneRingerOffGets a value indicating whether the phone's ringer is off (i.e., if it rings and/or vibrates).
PhoneRoamingGets a value indicating whether the phone is currently in roaming mode.
PhoneSearchingForServiceGets a value indicating whether the phone is currently searching for service on a network.
PhoneSignalStrengthGet the phone signal strength, expressed as a percentage of full strength.
PhoneSimFullGets a value indicating whether the Subscriber Identity Module (SIM) memory is full.
PhoneTalkingCallerContactGets the contact who is on the active phone call.
PhoneTalkingCallerContactPropertyIDGets the CEPROPID of the property of the contact who is on the active phone call, for example, PIMPR_HOME_TELEPHONE_NUMBER.
PhoneTalkingCallerContactPropertyNameGets the name of the property of the contact who is on the active phone call, e.g. "h" for "Home Telephone".
PhoneTalkingCallerNameGets the name of the person you are talking to on the phone. This value is not set when you are talking on a conference call.
PhoneTalkingCallerNumberGets the currently connected caller's phone number.
In order to return the status of these properties, you can use this simple code (as an example):
InitializeComponent(); SystemState _PhoneRoaming = new SystemState( SystemProperty.PhoneRoaming); _PhoneRoaming.Change += new ChangeEventHandler( _PhoneRoaming_Changed); void _PhoneRoaming_Changed(object sender, ChangeEventArgs args) { throw new Exception("The method or operation is not implemented."); } void _PhoneRoaming_Changed(object sender, ChangeEventArgs args) { if (SystemProperty.PhoneRoaming == false) { // Perform data network access } }
How do you debug applications that uses the phone network under an emulator?
There's a tool that ships with the SDK called FakeRIL or (Fake Radio Interface Layer) to simulate SMS and phone calls without actually having a cell network. Handy when using emulators for development. Barry Bond who used to work for the Mobile Team was the developer for the Windows Mobile emulators and he made a few posts and presented sessions on how you can use FakeRIL, here and here. Watch out for the "new version" when the new SDK is released, it has a lot more features than the old FakeRIL. When? Soon :)
Jim Wilson has also written two articles on programming the State and Notification Broker. Here's a BIG list of sample code for programming on Windows Mobile 5.0
Hope that helps.
* UPDATE: Daniel Moth has a Channel9 Video about using the State and Notification Broker. Check it out.