請問SDK說明書裡的 Initiation、Register callback、Check Nuwa Robot SDK engine is ready before app calling any
要如何做設定呢?
我使用 android studio
請問SDK說明書裡的 Initiation、Register callback、Check Nuwa Robot SDK engine is ready before app calling any
要如何做設定呢?
我使用 android studio
@chuangwater2487
Nuwa有提供一個GitHub Sample Code Open Sourec給開發者參考
https://github.com/nuwarobotics/NuwaSDKExample
這裡可以找找看有沒有你要的範例
我挑一個比較單純的範例給您參考(控制機器人講話的範例)
https://github.com/nuwarobotics/NuwaSDKExample/blob/master/app/src/main/java/com/nuwarobotics/example/voice/TTSActivity.java
在onCreate中有宣告監聽機器人事件callback
//Step 2 : Register receive Robot Event
mRobotAPI.registerRobotEventListener(robotEventListener);//listen callback of robot service event
而在robotEventListener 中,需要監看onWikiServiceStart有收到機器人回應服務連線了,在這之後,才能開始控制機器人。
RobotEventListener robotEventListener = new RobotEventListener() {
@Override
public void onWikiServiceStart() {
// Nuwa Robot SDK is ready now, you call call Nuwa SDK API now.
Log.d(TAG, "onWikiServiceStart, robot ready to be control");
//Step 3 : Start Control Robot after Service ready.
//Register Voice Callback event
mRobotAPI.registerVoiceEventListener(voiceEventListener);//listen callback of robot voice related event
//Allow user start demo after service ready
mSDKinit = true;
mStartBtn.setEnabled(true);
}