2011-04-17 48 views
1

我想使用Push註冊表在指定的時間啓動midlet。當我運行應用程序,即使時間超出的MIDlet未啓動..如何在特定時間自動啓動midlet?

公共無效的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

你有這個工作嗎? – Sydwell 2011-08-05 18:30:35

回答

1

爲了公平起見,我從來沒有使用過PushRegistry,但是從我閱讀的內容來看,您需要在middlet destroyApp()上安排時間警報。有看看這篇文章,向下滾動Registering a Timer Alarm

+0

我在我的問題中發佈的代碼中使用了相同的示例 – 2011-04-20 07:59:17

相關問題