短信拦截器 [英] smsInterceptor

查看:112
本文介绍了短信拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我目前正在研究一个项目,需要在Windows Mobile上使用SMS拦截器类.

我已经编写了代码.登录后出现的表单有两个按钮,一个按钮开始拦截SMS,另一个按钮开始侦听蓝牙.当我单击SMS按钮时,将执行以下代码:

Hello,

I am currently working on a project and need to use the SMS interceptor class on Windows Mobile.

I have written the code. The Form which comes up after logging in has two buttons, one to start intercepting SMS and another one to start Listening for Bluetooth. When I click on the SMS button, the following code is executed:

if (_statusSMS.Text == "Stopped") // We want to START as it is STOPPED
            {
                _sms.Text = "Stop SMS Module";

                sharedData.sms.MessageReceived += new MessageInterceptorEventHandler(sms_MsgRcvd);

                _statusSMS.Text = "Started";

            }



一旦启动,它就会按照我的要求正确开始拦截SMS.

但是,当按下另一个按钮进行蓝牙操作时:



Once started, it correctly starts intercepting SMSs as I want it to.

However though, when the other button is pressed for Bluetooth:

if (_statusBT.Text == "Stopped") // We want to START as it is STOPPED
            {
                _bluetooth.Text = "Stop Bluetooth Module";

                sharedData.stopBT = false;

                listener _listenerBT = new listener();
                _btThread1 = new Thread(new ThreadStart(_listenerBT.bluetooth)); // Start Bluetooth Thread
                _btThread2 = new Thread(new ThreadStart(_listenerBT.bluetoothMsg)); // Start Bluetooth Thread
                _btThread1.Start();
                _btThread2.Start();

                _statusBT.Text = "Started";

            }



然后,SMS拦截器将停止.直到我再次单击BT按钮以停止BT线程,然后SMS拦截器才能再次开始工作.当SMS拦截器停止时,在停止BT线程或关闭应用程序之前,不会在手机中接收SMS.



The SMS interceptor then stops. Until I click the BT Button again to stop BT thread, then the SMS interceptor starts working again. When the SMS Interceptor is stopped, the SMSs are not received in the mobile either until I stop the BT Thread or I close the application.

推荐答案

您是否尝试过蓝牙代码,尤其是侦听器在单独的线程中,以便它不会挂起主UI线程?
Have you tried having the Bluetooth code, especially the listener in a separate thread so that it does not hang the main UI thread?


将listenerBT的声明移到该方法之外(使其成为类级别的变量,而不是方法局部变量.)在执行时实例化它,并确保在BT停止代码中停止并销毁它.
Move the declaration for listenerBT outside this method (make it a class level variable, not a method local variable.) instantiate it as you do, and be sure to stop and destroy it in the BT stop code.


是的,它是在单独的线程中启动BT,但仍然在该线程启动后,SMS拦截器将不起作用.
Yes, it is starting the BT in a separate thread, but still the SMS Interceptor doesn''t work after that thread start.


这篇关于短信拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆