Mobile 定期从J2ME应用程序更新服务器

Mobile 定期从J2ME应用程序更新服务器,mobile,symbian,java-me,Mobile,Symbian,Java Me,我正在编写一个定期更新服务器的J2ME应用程序。如何使用J2ME实现功能?如何在启动时在手机上运行应用程序,以及如何保持其运行?。我计划在symbian平台上部署应用程序it实现这一点有几种方法。我认为最好使用单独的线程来处理服务器通信/更新: public class UpdateRunner extends Thread { ... public UpdateRunner() { // create an open sockets here }

我正在编写一个定期更新服务器的J2ME应用程序。如何使用J2ME实现功能?如何在启动时在手机上运行应用程序,以及如何保持其运行?。我计划在symbian平台上部署应用程序it

实现这一点有几种方法。我认为最好使用单独的线程来处理服务器通信/更新:

public class UpdateRunner extends Thread {
    ...
    public UpdateRunner() {
        // create an open sockets here
    }

    public void run() {
        while(true) {
            try {
                // send your messages/updates to server
            catch(...) {
                // handle errors like disconnections
            }
        }
    }
}
您还可以使用计时器定期运行某些代码:

private class ServerTask extends TimerTask {
    public void run() {
        // send message here 
    }
}
然后使用它:

Timer serverTimer = new Timer();
serverTimer .scheduleAtFixedRate(new ServerTask(), 0, 500);

关于在启动时运行它,我认为这是不可能的,因为JVM在允许软件随意使用网络方面存在一些安全问题。

有几种方法可以实现这一点。我认为最好使用单独的线程来处理服务器通信/更新:

public class UpdateRunner extends Thread {
    ...
    public UpdateRunner() {
        // create an open sockets here
    }

    public void run() {
        while(true) {
            try {
                // send your messages/updates to server
            catch(...) {
                // handle errors like disconnections
            }
        }
    }
}
您还可以使用计时器定期运行某些代码:

private class ServerTask extends TimerTask {
    public void run() {
        // send message here 
    }
}
然后使用它:

Timer serverTimer = new Timer();
serverTimer .scheduleAtFixedRate(new ServerTask(), 0, 500);

关于在启动时运行它,我认为这是不可能的,因为JVM在允许软件随意使用网络方面存在一些安全问题。

autostart MIDlet的功能称为Push Registry。 它允许各种事件启动midlet,通常是SMS或蓝牙。 索尼爱立信有一个推送注册变体,可以启动设备启动时的midlet,这至少在最新的基于Symbian的手机上得到支持。
对于诺基亚设备,我建议搜索诺基亚论坛。

autostart MIDlet的功能称为“推送注册表”。 它允许各种事件启动midlet,通常是SMS或蓝牙。 索尼爱立信有一个推送注册变体,可以启动设备启动时的midlet,这至少在最新的基于Symbian的手机上得到支持。 对于诺基亚设备,我建议搜索诺基亚论坛