Hi,

I am having problems to use the MessageInterceptor class on a
background app. It worked when I used a device app with a form. But
now, I try to use it in a console app because I want to run it as a
background process.

I have a main class, that is a Console App, that creates a SMSListener
class.
Then the main class calls the start method of the SMSListener:

public void Start()
{
MessageCondition msgCond = new
MessageCondition(MessageProperty.Sender, phoneNumber);
msi = new
MessageInterceptor(InterceptionAction.NotifyAndDelete,false);
msi.MessageCondition = msgCond ;
msi.MessageReceived += new
MessageInterceptorEventHandler(msi_MessageReceived);
}

Suppously when a message if intercepted it executes:

void msi_MessageReceived(object sender,
MessageInterceptorEventArgs e)
{
SmsMessage smsMessage = (SmsMessage)e.Message;
if (smsMessage.Body.StartsWith(keyWord))
{
// process message, show a message Box or any other
action
}
}


If I use a Device App with a Form there is no problem. It intercepts
the message coming from the number "phoneNumber" and process them if
they start with the keyword.

But I am using a Console App in the device, as background process, and
when a message is received from the number "phoneNumber" it displays
as normal message for the phone, and it goes to the Inbox.

Anyone can give a clue?

Cheers,
Victor

Re: MessageInterceptor by Peter

Peter
Thu May 17 11:12:42 CDT 2007

Are you using the overload of the MessageInterceptor constructor which
accepts the boolean argument userFormThread? - you need to set this to false
if using it from a console app.

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

"VicToro" <vicpada@googlemail.com> wrote in message
news:1179417376.584899.262780@n59g2000hsh.googlegroups.com...
> Hi,
>
> I am having problems to use the MessageInterceptor class on a
> background app. It worked when I used a device app with a form. But
> now, I try to use it in a console app because I want to run it as a
> background process.
>
> I have a main class, that is a Console App, that creates a SMSListener
> class.
> Then the main class calls the start method of the SMSListener:
>
> public void Start()
> {
> MessageCondition msgCond = new
> MessageCondition(MessageProperty.Sender, phoneNumber);
> msi = new
> MessageInterceptor(InterceptionAction.NotifyAndDelete,false);
> msi.MessageCondition = msgCond ;
> msi.MessageReceived += new
> MessageInterceptorEventHandler(msi_MessageReceived);
> }
>
> Suppously when a message if intercepted it executes:
>
> void msi_MessageReceived(object sender,
> MessageInterceptorEventArgs e)
> {
> SmsMessage smsMessage = (SmsMessage)e.Message;
> if (smsMessage.Body.StartsWith(keyWord))
> {
> // process message, show a message Box or any other
> action
> }
> }
>
>
> If I use a Device App with a Form there is no problem. It intercepts
> the message coming from the number "phoneNumber" and process them if
> they start with the keyword.
>
> But I am using a Console App in the device, as background process, and
> when a message is received from the number "phoneNumber" it displays
> as normal message for the phone, and it goes to the Inbox.
>
> Anyone can give a clue?
>
> Cheers,
> Victor
>


Re: MessageInterceptor by VicToro

VicToro
Fri May 18 05:03:57 CDT 2007

It turned out to be that I was using a bad phone number format.

I was using 003538.... and I should use +3538...

It solved the problem of intercepting the message.

I am able to show a message box with the intercepted message.


Cheers,
Victor