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:

Phone1xRttCoverage
Gets a value indicating whether the phone currently has 1xRTT coverage.

PhoneActiveCallCount
Gets the number of active phone calls.

PhoneActiveDataCall
Gets a value indicating whether the phone has an active cellular data connection.

PhoneBlockedSim
Gets a value indicating whether the Subscriber Identity Module (SIM) is blocked.

PhoneCallBarring
Gets a value indicating whether the call barring feature is enabled.

PhoneCallCalling
Gets a value indicating whether the phone is currently attempting to connect an outgoing call.

PhoneCallForwardingOnLine1
Gets a value indicating whether call forwarding is enabled on line 1.

PhoneCallForwardingOnLine2
Gets a value indicating whether call forwarding is currently active on line 2.

PhoneCallOnHold
Gets a value indicating whether a phone call is currently on hold.

PhoneCallTalking
Gets a value indicating whether there is currently a phone call in the talking state.

PhoneCellBroadcast
Gets the cell broadcast message

PhoneConferenceCall
Gets a value indicating whether a conference call is currently in progress.

PhoneGprsCoverage
Gets a value indicating whether the phone currently has GPRS coverage.

PhoneHomeService
Gets a value indicating whether the phone is currently registered on its home network.

PhoneIncomingCall
Gets a value indicating whether there is an incoming (ringing) call.

PhoneIncomingCallerContact
Gets the Contact that matches the Caller ID.

PhoneIncomingCallerContactPropertyID
Gets the CEPROPID of the property that matches the Caller ID, for example, PIMPR_HOME_TELEPHONE_NUMBER.

PhoneIncomingCallerContactPropertyName
Gets the name of the property that matches the Caller ID, e.g. "h" for "Home Telephone".

PhoneIncomingCallerName
Gets the name of the person who is currently placing the incoming call.

PhoneIncomingCallerNumber
Gets the incoming call's phone number (Caller ID).

PhoneInvalidSim
Gets a value indicating whether the Subscriber Identity Module (SIM) is invalid.

PhoneLastIncomingCallerContact
Gets the Contact that matches the last Caller ID.

PhoneLastIncomingCallerContactPropertyID
Gets the CEPROPID of the property that matches the last Caller ID, for example, PIMPR_HOME_TELEPHONE_NUMBER.

PhoneLastIncomingCallerContactPropertyName
Gets the name of the property that matches the last Caller ID, e.g. "h" for "Home Telephone".

PhoneLastIncomingCallerName
Gets the name of the last caller to place an incoming call.

PhoneLastIncomingCallerNumber
Gets the last incoming call's phone number (Caller ID).

PhoneLine1Selected
Gets a value indicating whether line 1 is selected.

PhoneLine2Selected
Gets a value indicating whether line 2 is selected.

PhoneMissedCall
Gets a value indicating whether there was a new missed call.

PhoneMissedCalls
Gets the number of missed phone calls.

PhoneMultiLine
Gets a value indicating whether the phone supports multiple lines.

PhoneNoService
Gets a value indicating whether the phone is not currently connected to a network.

PhoneNoSim
Gets a value indicating whether the Subscriber Identity Module (SIM) is installed in the mobile device.

PhoneOperatorName
Gets the name of the mobile operator (i.e., the mobile phone company, or carrier).

PhoneProfile
Gets the non-localized name of the current sound profile. For example, "Normal", "Silent", "Car", "Headset", "Loud", "Meeting", or "Speakerphone". (Smartphone only)

PhoneProfileName
Gets the localized name of the current sound profile. (Smartphone only)

PhoneRadioOff
Gets a value indicating whether the phone's radio is turned off.

PhoneRadioPresent
Gets a value indicating whether the mobile device has a phone.

PhoneRingerOff
Gets a value indicating whether the phone's ringer is off (i.e., if it rings and/or vibrates).

PhoneRoaming
Gets a value indicating whether the phone is currently in roaming mode.

PhoneSearchingForService
Gets a value indicating whether the phone is currently searching for service on a network.

PhoneSignalStrength
Get the phone signal strength, expressed as a percentage of full strength.

PhoneSimFull
Gets a value indicating whether the Subscriber Identity Module (SIM) memory is full.

PhoneTalkingCallerContact
Gets the contact who is on the active phone call.

PhoneTalkingCallerContactPropertyID
Gets the CEPROPID of the property of the contact who is on the active phone call, for example, PIMPR_HOME_TELEPHONE_NUMBER.

PhoneTalkingCallerContactPropertyName
Gets the name of the property of the contact who is on the active phone call, e.g. "h" for "Home Telephone".

PhoneTalkingCallerName
Gets 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.

PhoneTalkingCallerNumber
Gets 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.