当前位置: 技术问答>java相关
这个监听器如何注册(j2me 关于短信的到来)(分不够再加)
来源: 互联网 发布时间:2015-08-29
本文导语: 我在开发关于手机收短信的的程序,我希望可以在我收到短信的时间,程序中可以监听到,请问代码我应如何写。 现假设的初始环境是我在查看其他的信息,我写了以下三个类 MIDletstart.java //MIDlet SendSms.java //发送...
我在开发关于手机收短信的的程序,我希望可以在我收到短信的时间,程序中可以监听到,请问代码我应如何写。
现假设的初始环境是我在查看其他的信息,我写了以下三个类
MIDletstart.java //MIDlet
SendSms.java //发送短信
MainList.java //其他的例如我正在查看一些其他的信息的一个类
我希望我可以在查看其他的一些信息的时间我可以监听到短信的到来。
希望能有代码示例
现假设的初始环境是我在查看其他的信息,我写了以下三个类
MIDletstart.java //MIDlet
SendSms.java //发送短信
MainList.java //其他的例如我正在查看一些其他的信息的一个类
我希望我可以在查看其他的一些信息的时间我可以监听到短信的到来。
希望能有代码示例
|
这种监听各个手机厂商提供的api中都会定义的,例如在siemens定义的中就有这种接口
com.siemens.mp.io
Interface ConnectionListener
--------------------------------------------------------------------------------
public interface ConnectionListener
The ConnectionListener interface defines the capabilities for the connection's incoming data receiver. When the user wants to receive data on a connection, an implementation class for the ConnectionListener interface must first be created first. The receiveData method of this class must contain the incoming data processing code. After connection opening, this class instance is to be passed as a parameter to the Connection.setListener method call. After that, the receiveData method will be called by the runtime system each time incoming data from the given connection arrives.
至于具体的用法,我测试完后再说吧!
com.siemens.mp.io
Interface ConnectionListener
--------------------------------------------------------------------------------
public interface ConnectionListener
The ConnectionListener interface defines the capabilities for the connection's incoming data receiver. When the user wants to receive data on a connection, an implementation class for the ConnectionListener interface must first be created first. The receiveData method of this class must contain the incoming data processing code. After connection opening, this class instance is to be passed as a parameter to the Connection.setListener method call. After that, the receiveData method will be called by the runtime system each time incoming data from the given connection arrives.
至于具体的用法,我测试完后再说吧!