[Cf. Skills]. Net CF phone status capture (Part 1)

Source: Internet
Author: User
Abstract: This article describes how For Windows Mobile 5.0 Obtain the phone status in the above system, such as connection or hanging up, C # Description.
Keywords
Windows Mobile,. Net CF, phonestate, systemstate, C #, bug

I wrote an article earlier:

[Cf. Skills]In. NET Compact frameworkObtain and shield incoming callsThis article is part of its append.

some friends BBS on or on my blog the above message asks you how to know the call status, such as connection, ( wait ) . the traditional method is to use, Windows CE Telephony API (TAPI) , however, you may need to write Code , which may involve some callback functions. See SDK cellcore example.
On Windows Mobile 5 you can use TAPI wrapper to implement its functions in managed code. for example, systemproperty. phonecalltalking and systemproperty. phoneactivecallcount .

The followingProgramDemonstrate how to use them to get the phone status:

Public Void listencall ()
{
Callstate =   New Systemstate (systemproperty. phonecalltalking );
Callcount =   New Systemstate (systemproperty. phoneactivecallcount );
Callstate. Changed + =   New Changeeventhandler (callstate_changed );
Callcount. Changed + =   New Changeeventhandler (callcount_changed );
}

Void callcount_changed ( Object Sender, changeeventargs ARGs)
{
If (ARGs. newvalue! = Null && ( Int ) Args. newvalue! = 0 )
MessageBox. Show ( " Call incoming " );
}

Void callstate_changed ( Object Sender, changeeventargs ARGs)
{
If (ARGs. newvalue! = Null)
{
String State = (( Int ) Args. newvalue) =   1 ? " Talking " : " Hang up " ;
MessageBox. Show (State );
}
}

 
Running effect:
Incoming call

answer phone
suspend
both subscribed events are useful, callstate. changed this event is used to determine whether a call is in progress. Once the call status changes, this event is triggered. When the call is in progress, the event parameter value is true , the event parameter value is false . callcount. changed is the number of currently connected lines. When an incoming call is available + 1 ( default value: 0 ) , -1 .

But I found a problem here, maybe it isCfOfBug. When I remove or replaceMessageBox. Show ("Call incoming ...");In this sentence,Callstate. ChangedIt seems that it will never be triggered. I usedWm6 pro emulator + cellular emulatorTest. On my device(Intel XScale 416 MHz, wm5 PPC phone,. Net CF 3.5)Test, press the answer key and then immediately displayPhoneDialog box, which cannot be triggeredCallstate. ChangedIt seems that the thread of the event listening is blocked. Is this true?CfOfBugFurther tests are pending.
Download sample here: Sample download


 

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.