1. gzyueqian
      18529173453
      首頁 > 新聞中心 > > 正文

      在索尼愛立信JP7平臺上自動啟動MIDlet

      更新時間: 2007-05-16 13:47:59來源: 粵嵌教育瀏覽量:773


        開機(jī)就能自動啟動MIDlet一直是J2ME開發(fā)者的夢想,這一夢想在索尼愛立信的JP7平臺上實現(xiàn)了。不過需要注意的是早期的幾款機(jī)型不支持,比如K790等。具體請參考索尼愛立信的手冊。

        開機(jī)自啟動功能是通過Push注冊來完成的,因此可以使用兩種方式來注冊。種通過在jad文件注明PUSH注冊的方式即可,如下。

      //MIDlet-Push-<n>: <ConnectionURL>, <MIDletClassName>, <AllowedSender>
      MIDlet-Push-1: autostart://:, AutoStartStatic, *

        請注意URL的寫法是autostart://:

        如果想動態(tài)注冊,可以通過下面的方法。

      //Registers the pushRegistry
      public void Register(){
      // List of registered push connections.
      String connections[];
      // Check to see if the connection has been registered.
      // This is a dynamic connection allocated on first
      // time execution of this MIDlet.
      connections = PushRegistry.listConnections(false);
      if (connections.length == 0) {
      try {
      //Register so the MIDlet will wake up when phone is started.
      PushRegistry.registerConnection("autostart://:", "AutoStartDyn", "*");
      sDisplayString = "MIDlet is registered";
      } catch (Exception ex) {
      System.out.println("Exception: " + ex);
      sDisplayString = "Fail: " + ex;
      }
      } else {
      sDisplayString = "Already registered";
      }
      displayForm.deleteAll();
      displayForm.append(sDisplayString);
      }

      //Unregisters the pushRegistry
      public void Unregister(){
      if (PushRegistry.unregisterConnection("autostart://:")){
      System.out.println("The pushRegistry is unregistered");
      sDisplayString = "MIDlet is unregistered.";
      }else{
      System.out.println("There is no pushRegistry to unregister");
      sDisplayString = "No MIDlet to unregister or failed to unregister";
      }
      displayForm.deleteAll();
      displayForm.append(sDisplayString);
      }

        由于手頭沒有SonyEricsson JP7平臺的手機(jī),因此沒有辦法測試開機(jī)自動啟動功能。有條件的可以自己測試一下。

      免費預(yù)約試聽課

      亚洲另类欧美综合久久图片区_亚洲中文字幕日产无码2020_欧美日本一区二区三区桃色视频_亚洲AⅤ天堂一区二区三区

      
      

      1. 日本在线视频一区 | 在线亚洲精品字募免费视频 | 一区二区三区高清在綫无碼 | 精品久久免费视频观看 | 亚洲精品色在线网站 | 五月天丁香开心婷婷 |