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

Source: Internet
Author: User

Abstract: This article describes howFor Windows Mobile 5.0Obtain 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 I left a message asking how to know the call status, such as connection, ( wait ) . the traditional method is to use, Windows CE , however, you may need to write Code , which may involve some callback functions. For more information, see SDK cellcore .
On Windows Mobile 5 wrapper of "> implements 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
pending
both subscribed events are useful, callstate. changed is used to determine whether the call is in progress. Once the 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 ( the default value is 0 ) . When the file is hung up, -1 .

however, I found a problem, maybe cf . When I remove or replace MessageBox. show ("Call incoming... "); callstate. changed it seems that it will never be triggered. I used the wm6 pro emulator + cellular emulator test. On my device (Intel XScale 416 MHz, wm5 PPC phone ,. net CF 3.5) in the test, the phone phone dialog box still does not support triggering callstate. changed , it seems that the thread of the event listening is blocked, is this a cf bug further tests are pending.
Download sample here: Sample download

regards
freesc Huang
yellow winter @ HUST

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.