.NET: Detect Incoming Call or SMS in Windows Mobile Phone
By admin on Mar 3, 2008 in .NET, Programming
I was looking for way to detect incoming call or SMS in Nokia Symbian phones and Windows Mobile Phone. It was not easy to do this in Symbian OS but to do it in .NET is very straightforward.
messageInterceptor = new MessageInterceptor(); messageInterceptor.InterceptionAction = InterceptionAction.NotifyAndDelete; //messageInterceptor.MessageCondition.CaseSensitive = true; //messageInterceptor.MessageCondition.Property = // MessageProperty.Sender; messageInterceptor.MessageReceived += new MessageInterceptorEventHandler(Message_Received); SystemState s; s = new SystemState(SystemProperty.PhoneIncomingCall); s.Changed += new ChangeEventHandler(PhoneEvents_Triggered); stateList.Add(s); s = new SystemState(SystemProperty.PhoneIncomingCallerName); s.Changed += new ChangeEventHandler(PhoneEvents_Triggered); stateList.Add(s); s = new SystemState(SystemProperty.PhoneIncomingCallerNumber); s.Changed += new ChangeEventHandler(PhoneEvents_Triggered); stateList.Add(s); s = new SystemState(SystemProperty.PhoneLastIncomingCallerContact); s.Changed += new ChangeEventHandler(PhoneEvents_Triggered); stateList.Add(s); s = new SystemState( SystemProperty.PhoneIncomingCallerContactPropertyName); s.Changed += new ChangeEventHandler(PhoneEvents_Triggered); stateList.Add(s);
As you can see, I only need to use the MessageInterceptor class, and set the event handler to the method Message_Received.
void Message_Received(object sender, MessageInterceptorEventArgs e) { if (e.Message is SmsMessage) { SmsMessage sms = (SmsMessage)e.Message; txtMsg.Text += sms.Body + "\r\n"; } txtMsg.Text += e.Message.From.Address.ToString() + "\n" + e.Message.From.Name.ToString() + "r\n"; }
And to do this in my Nokia N70 I have to use C++. It is not possible to use J2ME to achieve this yet.
Avinash Shrimali | May 13, 2008 | Reply
Good
Eko | Aug 26, 2008 | Reply
thx for your tutorial.but, do u have similar code write on VB?
david | Dec 8, 2008 | Reply
It is a great incredible program for me.I am doing a similar program,Could you send me a copy of code in c/c++??Thank you very much!!
kumiorava | May 12, 2009 | Reply
Check out WMA API (JSR-120) for incoming SMS detection on Nokia N70 Java. I would guess you need signed (trusted) application to be able to use that API, but it should work.