我想使用Push注册表在指定时间启动midlet。当我运行应用程序时,即使超过时间,midlet也不会启动..
public void startApp(){
System.out.println( "AlarmMIDlet: startApp" );
try {
Date now = new Date();
long previous;
String cn = this.getClass().getName();
System.out.println("Class name : "+cn);
previous = PushRegistry.registerAlarm( "hello.AlarmMIDlet", now.getTime() + 600 );
System.out.println( "AlarmMIDlet: time of previous alarm: " + previous );
} catch ( java.lang.ClassNotFoundException cnf ) {
System.out.println( "AlarmMIDlet: Class not Found" );
} catch ( javax.microedition.io.ConnectionNotFoundException connnf ) {
System.out.println( "AlarmMIDlet: Connection Not Found" );
}
System.out.println( "AlarmMIDlet: startApp: return" );
notifyDestroyed();
}
任何人都遇到过类似的问题?如何解决这个问题?
答案 0 :(得分:1)
公平地说,我从未使用过PushRegistry,但从我读过的内容来看,你需要在middlet destroyApp()上安排时间报警。看看这篇文章,向下滚动Registering a Timer Alarm