【问题标题】:Native Interface for J2Me device Codename OneJ2Me 设备代号一的本机接口
【发布时间】:2014-08-02 22:55:07
【问题描述】:

我创建了一个接口类:

  package userclasses;
  import com.codename1.system.NativeInterface;

   public interface NativeJ2MEInterface extends NativeInterface {

       public void pollBackground();
   }

这是原生类 - 在我编辑后:

  package userclasses;
  import userclasses.StateMachine;

  public class NativeJ2MEInterfaceImpl {

      public void pollBackground() {

         try {
            Date now = new Date();
            long timeToRun = now.getTime() + (1000 * 60 );

            System.out.println("RUNNNNNNN forest runnn!");

            PushRegistry.registerAlarm(StateMachine.class.getName(), timeToRun);
          }
          catch (Exception e) {
             System.out.println("EXC-1:"+e.getMessage());
          }

      }

      public boolean isSupported() {
          return true;
      }

  }

我想调用 javax.microedition.io.PushRegistry registerAlarm 方法,但我的 Codename One J2ME 构建失败,提示:

  error: cannot find symbol
  PushRegistry.registerAlarm(StateMachine.class.getName(), timeToRun);

我在本地 j2me 目录中添加了一个 midp_2.1.jar,但它不起作用。 我怎样才能让它工作?或者如何直接访问j2me报警API?

【问题讨论】:

    标签: java-me native codenameone


    【解决方案1】:

    不要添加jar,它会被打包到最终构建中。

    尝试设置构建参数j2me.ashaNative=true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-01
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      • 2020-02-18
      • 1970-01-01
      相关资源
      最近更新 更多