lulu88
lulu88

Reputation: 1714

Native Interface for J2Me device Codename One

I created an Interface class:

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

   public interface NativeJ2MEInterface extends NativeInterface {

       public void pollBackground();
   }

This is the native class - after I edited it:

  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;
      }

  }

I want to call the javax.microedition.io.PushRegistry registerAlarm method, but my Codename One J2ME build fails saying:

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

I added a midp_2.1.jar to the native j2me directory, but it did not work. How can I get this to work? Or how can I directly access j2me alarm API?

Upvotes: 1

Views: 144

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

Don't add the jar, it will get packaged into the final build.

Try setting the build argument j2me.ashaNative=true.

Upvotes: 2

Related Questions