{"id":539,"date":"2023-03-30T17:31:02","date_gmt":"2023-03-30T09:31:02","guid":{"rendered":"https:\/\/doc.orionstar.com\/en\/?post_type=lsvr_kba&#038;p=539"},"modified":"2023-05-30T17:50:54","modified_gmt":"2023-05-30T09:50:54","slug":"sdk-access","status":"publish","type":"lsvr_kba","link":"https:\/\/doc.orionstar.com\/en\/knowledge-base\/sdk-access\/","title":{"rendered":"SDK Access"},"content":{"rendered":"\n<h3 id=\"sdk-access-sdk-access-find-the-right-version-sdk\"><strong>Find the right version SDK<\/strong><a href=\"https:\/\/ainirobot.gatsbyjs.io\/docs\/apk\/apk-development\/#sdk-access-sdk-access-find-the-right-version-sdk\"><\/a><\/h3>\n\n\n\n<p>Most of the robot using the same SDK, download the Robot APP sample you can find it under libs folder.<\/p>\n\n\n\n<p>Robot APP Sample Code:&nbsp;<a href=\"https:\/\/github.com\/OrionStarGIT\/RobotSample\" target=\"_blank\" rel=\"noreferrer noopener\">Download<\/a><\/p>\n\n\n\n<h3 id=\"sdk-access-sdk-access-configure-the-default-launcher\"><strong>Configure the default launcher<\/strong><a href=\"https:\/\/ainirobot.gatsbyjs.io\/docs\/apk\/apk-development\/#sdk-access-sdk-access-configure-the-default-launcher\"><\/a><\/h3>\n\n\n\n<p>Configure Manifest file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;activity android:name=\".MainActivity\">    \n    &lt;intent-filter>        \n        &lt;action android:name=\"android.intent.action.MAIN\"\/>        \n        &lt;category android:name=\"android.intent.category.LAUNCHER\"\/>    \n    &lt;\/intent-filter>    \n    &lt;intent-filter>        \n        &lt;action android:name=\"action.orionstar.default.app\" \/>        \n        &lt;category android:name=\"android.intent.category.DEFAULT\" \/>    \n    &lt;\/intent-filter>\n&lt;\/activity><\/pre>\n\n\n\n<p>If the App needs to be launched by default after booting, it needs to be configured in the Manifest.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;intent-filter>    \n    &lt;action android:name=\"action.orionstar.default.app\" \/>    \n    &lt;category android:name=\"android.intent.category.DEFAULT\" \/>\n&lt;\/intent-filter><\/pre>\n\n\n\n<p>And set in the settings (three-finger pull down and click on the settings to enter)-Boot Apps<img decoding=\"async\" src=\"https:\/\/ainirobot.gatsbyjs.io\/assets\/docs\/kyma\/master\/apk-development\/docs\/assets\/boot_app.png\">&nbsp;<\/p>\n\n\n\n<p>For complete SDK access, the following permissions need to be declared in AndroidManifest.xml<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    &lt;uses-permission android:name=\"android.permission.INTERNET\"\/>\n    &lt;uses-permission android:name=\"com.ainirobot.coreservice.robotSettingProvider\" \/>\n    &lt;uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"\/>\n    &lt;uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"\/><\/pre>\n\n\n\n<h3 id=\"sdk-access-sdk-access-sdk-access\"><strong>SDK access<\/strong><a href=\"https:\/\/ainirobot.gatsbyjs.io\/docs\/apk\/apk-development\/#sdk-access-sdk-access-sdk-access\"><\/a><\/h3>\n\n\n\n<ol start=\"1\">\n<li>Create a callback for receiving voice requests and system events<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class ModuleCallback extends ModuleCallbackApi {    \n    @Override    \n    public boolean onSendRequest(int reqId, String reqType, String reqText, String reqParam)    throws RemoteException {        \n        \/\/receive voice command,        \n        \/\/reqTyp : voice command type        \n        \/\/reqText : voice to text        \n        \/\/reqParam : voice command parameter        \n        return true;    \n    }    \n    @Override    \n    public void onRecovery()    throws RemoteException {        \n        \/\/When receiving the event, regain control of the robot    \n    }    \n    @Override    \n    public void onSuspend()    throws RemoteException {        \n        \/\/Control is deprived by the system. When receiving this event, all Api calls are invalid    \n    }\n}<\/pre>\n\n\n\n<ol start=\"2\">\n<li>Connect to the server<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">RobotApi.getInstance().connectServer(this, new ApiListener() {    \n    @Override    \n    public void handleApiDisabled() {\n    }    \n    @Override    \n    public void handleApiConnected() {        \n        \/\/ Server is connected, set the callback for receiving requests, including voice commands, system events, etc.        \n        RobotApi.getInstance().setCallback(new ModuleCallback());    \n    }    \n    @Override    \n    public void handleApiDisconnected() {        \n        \/\/Disconnect    \n    }\n});<\/pre>\n\n\n\n<p><em>Note: All APIs can only be called after successfully connecting to the server<\/em><\/p>\n\n\n\n<ol start=\"3\">\n<li>Set callback<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">RobotApi.getInstance().setCallback(new ModuleCallback());<\/pre>\n\n\n\n<ol start=\"4\">\n<li>End instruction<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">RobotApi.getInstance().finishModuleParser(reqId, result);<\/pre>\n\n\n\n<p>When the received request or voice command is processed, finishModuleParser needs to be called to end the command, reqId is obtained in the onSendRequest callback, and result is the execution result<\/p>\n\n\n\n<ol start=\"5\">\n<li>Registration status monitoring<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">StatusListener statusListener = new StatusListener() {    \n    @Override    \n    public void onStatusUpdate(String type, String data) throws RemoteException \n    {\n    };\n}\nRobotApi.getInstance().registerStatusListener(type, statusListener);\nRobotApi.getInstance().unregisterStatusListener(statusListener);<\/pre>\n\n\n\n<p>&#8216;type&#8217; is the type of state that needs to be monitored, and type supports the following:<\/p>\n\n\n\n<ul>\n<li>Definition.STATUS_POSE: The current coordinates of the robot, continuously reported<\/li>\n\n\n\n<li>Definition.STATUS_POSE_ESTIMAT: current positioning status, reported when the positioning status changes<\/li>\n\n\n\n<li>Definition.STATUS_BATTERY\uff1aCurrent battery status information, including whether it is charging, how much power is left, and whether there is a low battery warning.<\/li>\n<\/ul>\n\n\n\n<ol start=\"6\">\n<li>Set reqId<\/li>\n<\/ol>\n\n\n\n<p>Many SDK methods need to pass in the parameter reqId, which is an id used for debugging and tracking logs. Passing in any number can make the function work normally, but for the convenience of log tracking and debugging, it is recommended to make reqid an self-increasing static variable, or pass in different reqId to distinguish the calling function according to business needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find the right version SDK Most of the robot using the same SDK, download the Robot APP sample you can find it under libs folder. Robot APP Sample Code:&nbsp;Download Configure the default launcher Configure Manifest file If the App needs to be launched by default after booting, it needs to be configured in the Manifest. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":[],"lsvr_kba_cat":[6],"lsvr_kba_tag":[],"_links":{"self":[{"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba\/539"}],"collection":[{"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba"}],"about":[{"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/types\/lsvr_kba"}],"author":[{"embeddable":true,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":3,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba\/539\/revisions"}],"predecessor-version":[{"id":624,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba\/539\/revisions\/624"}],"wp:attachment":[{"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"lsvr_kba_cat","embeddable":true,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba_cat?post=539"},{"taxonomy":"lsvr_kba_tag","embeddable":true,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba_tag?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}