-1

I want to communicate between Nao V3 and Android application, I use Naoqi 2.1.4.13 and Java. I want to connect them together and interact. For example : The user clic on the "Connect" button and this will connect the robot to the interface and then the user select on the application the Tai Chi danse and this will launch the Tai Chi behavior. I have the Java API and I can communicate with the robot with a Java class and a main function without the interface. But I want to do it with the interface. The problem is that my android project on android studio doesn't have a public static void main(String[]args) function, just a protected void onCreate(Bundle savedInstanceState) function. Can you help me with my problem please ?

I already tried to communicate without the main function one the MainActivity java class of my Android application. But it doesn't work.

I try :

 private Application app = null;
private Session session = null;
protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        app = new Application(null);
    }

following this example.

and I have this error who appear :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication1/com.example.myapplication1.MainActivity}:
 java.lang.RuntimeException: Creating application with null args
Caused by: java.lang.RuntimeException: Creating application with null args
        at com.aldebaran.qi.Application.<init>(Application.java:59)
        at com.example.myapplication1.MainActivity.onCreate(MainActivity.java:35)
        at android.app.Activity.performCreate(Activity.java:6662)

When I try in a java class without launching the application it's working:

 public static void main(String[] args) throws Exception{
    Application app = new Application(args);
    Session session = new Session();
    session.connect("tcp://" + NAO_IP + ":9559").sync(500, TimeUnit.MILLISECONDS);
    Object tts = null;

    ALBehaviorManager alBehaviorManager = new ALBehaviorManager(session);}
JJIqbal
  • 630
  • 1
  • 8
  • 23
  • 1
    Why do you think you need a `main` to do this? We can't really help you if you don't show us the code you currently have. – MrPromethee Jun 06 '19 at 14:19
  • I think it's the argument in the Application constructor ! Because with the String[]args in the main function it's working! And with a null or new String[]{} in th constructor on the OnCreate function it's not working – Delphine Raoux Jun 07 '19 at 06:50

2 Answers2

0

You need that String[] args to be passed to Application's constructor. A dummy String[] should probably do.

Victor Paléologue
  • 2,025
  • 1
  • 17
  • 27
0

When I try this:

String[] arg = new String[]{"robot_app"};
    public Application app;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    app = new Application(arg);
}

I have this kind of error :

Process: com.example.myapplication1, PID: 28357
    java.lang.UnsatisfiedLinkError: No implementation found for long com.aldebaran.qi.Application.qiApplicationCreate(java.lang.String[], java.lang.String, boolean) (tried Java_com_aldebaran_qi_Application_qiApplicationCreate and Java_com_aldebaran_qi_Application_qiApplicationCreate___3Ljava_lang_String_2Ljava_lang_String_2Z)
        at com.aldebaran.qi.Application.qiApplicationCreate(Native Method)
        at com.aldebaran.qi.Application.init(Application.java:65)
        at com.aldebaran.qi.Application.<init>(Application.java:60)
        at com.example.myapplication1.MainActivity.onCreate(MainActivity.java:32)
        at android.app.Activity.performCreate(Activity.java:6662)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)