{"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":"2026-11-03T11:00:54","modified_gmt":"2026-11-03T03:00: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<p class=\"has-medium-font-size\"><strong>All Robots Except a Few Older Models Use the Same SDK<\/strong><\/p>\n\n\n\n<p>The robots now share a single, unified SDK, which is included in the demo program. Download the demo program and copy the SDK library file from its libs folder.<\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"sample-code\"><strong><a href=\"#sample-code\">Sample Code<\/a><\/strong><\/p>\n\n\n\n<p>Demo program download: <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/OrionStarGIT\/RobotSample\" target=\"_blank\">Click to download<\/a><\/p>\n\n\n\n<p><strong><mark class=\"has-inline-color has-vivid-red-color\">Note: <\/mark><\/strong>For the SDK used in the demo, download the jar that matches the robot&#8217;s system from the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/OrionStarGIT\/RobotSample\/releases\" data-type=\"URL\" data-id=\"https:\/\/github.com\/OrionStarGIT\/RobotSample\/releases\" target=\"_blank\">releases <\/a>page.<\/p>\n\n\n\n<p>Configure the default launch app<\/p>\n\n\n\n<p>Configure the Manifest file<\/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;activity android:name=\".MainActivity\"&gt;\n    &lt;intent-filter&gt;\n        &lt;action android:name=\"android.intent.action.MAIN\"\/&gt;\n        &lt;category android:name=\"android.intent.category.LAUNCHER\"\/&gt;\n     &lt;\/intent-filter&gt;\n     &lt;intent-filter&gt;\n         &lt;action android:name=\"action.orionstar.default.app\" \/&gt;\n         &lt;category android:name=\"android.intent.category.DEFAULT\" \/&gt;\n     &lt;\/intent-filter&gt;\n&lt;\/activity&gt;<\/pre>\n\n\n\n<p>If the app needs to launch by default after the robot boots, configure the following 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&gt;\n    &lt;action android:name=\"action.orionstar.default.app\" \/&gt;\n    &lt;category android:name=\"android.intent.category.DEFAULT\" \/&gt;\n&lt;\/intent-filter&gt;<\/pre>\n\n\n\n<p>Then set it in Settings (swipe down with three fingers and tap Settings) &#8211; Developer Settings \u2013 Boot Apps<\/p>\n\n\n\n<p><strong><em>Note: The Boot Apps setting was officially released in OTA3<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"permissions\"><strong><a href=\"#permissions\">Permissions<\/a><\/strong><\/p>\n\n\n\n<p>For full SDK integration, declare the following permissions 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\"\/&gt;\n&lt;uses-permission android:name=\"com.ainirobot.coreservice.robotSettingProvider\" \/&gt;\n&lt;uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"\/&gt;\n&lt;uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"\/&gt;<\/pre>\n\n\n\n<p class=\"has-medium-font-size\" id=\"sdk-access\"><strong><a href=\"#sdk-access\">SDK Access<\/a><\/strong><\/p>\n\n\n\n<p>1. Create a callback for receiving voice requests and system events<\/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=\"\">public class ModuleCallback extends ModuleCallbackApi {\n    @Override\n    public boolean onSendRequest(int reqId, String reqType, String reqText, String reqParam)\n            throws RemoteException {\n        \/\/Receive voice commands\n        \/\/reqTyp : Voice command type\n        \/\/reqText : Speech recognition text\n        \/\/reqParam : Voice command parameters\n        return true;\n    }\n    @Override\n    public void onRecovery()\n            throws RemoteException {\n           \/\/Control is restored. After receiving this event, resume control of the robot\n\n    }\n    @Override\n    public void onSuspend()\n            throws RemoteException {\n           \/\/Control has been taken away by the system. After receiving this event, all API calls are invalid\n\n    }<\/pre>\n\n\n\n<p>2. Connect to the server<\/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=\"\">RobotApi.getInstance().connectServer(this, new ApiListener() {\n    @Override\n    public void handleApiDisabled() {\n    }\n    @Override\n    public void handleApiConnected() {\n        \/\/Server 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        \/\/Disconnected\n    }\n});<\/pre>\n\n\n\n<p>Initializing the robot SDK means the robot hands over control of the chassis capabilities to the app that is currently running. The robot triggers the disconnected callback when the system takes over, when a fault occurs, or when another program that uses the robot SDK is started. Of these, the connection is re-established only when the system takeover ends.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><em>Note 1: All APIs can be called only after the connection to the server succeeds<\/em><\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><em>Note 2: Only a foreground process running in the foreground can connect correctly and obtain control of the robot chassis. Service processes do not work.<\/em><\/p>\n\n\n\n<p>3. Set the callback<\/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=\"\">RobotApi.getInstance().setCallback(new ModuleCallback());<\/pre>\n\n\n\n<p>4. Finish the command<\/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=\"\">RobotApi.getInstance().finishModuleParser(reqId, result);<\/pre>\n\n\n\n<p>After a received request or voice command has been processed, call finishModuleParser to finish the command. reqId is obtained from the onSendRequest callback, and result is the execution result.<\/p>\n\n\n\n<p>5. Register a status listener<\/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=\"\">StatusListener statusListener = new StatusListener(){\n    @Override\n    public void onStatusUpdate(String type, String data) throws RemoteException {\n    };\n}\n\/\/Register the status listener\nRobotApi.getInstance().registerStatusListener(type, statusListener);\n\/\/Unregister the status listener\nRobotApi.getInstance().unregisterStatusListener(statusListener);<\/pre>\n\n\n\n<p>type is the status type to listen for. The following types are supported:<\/p>\n\n\n\n<ul>\n<li>Definition.STATUS_POSE: The robot&#8217;s current coordinates, reported continuously<\/li>\n\n\n\n<li>Definition.STATUS_POSE_ESTIMATE: The current localization status, reported when the localization status changes<\/li>\n\n\n\n<li>Definition.STATUS_BATTERY: Current battery status information, including whether it is charging, the battery level, whether there is a low-battery warning, and so on<\/li>\n<\/ul>\n\n\n\n<p>6. Set reqId<\/p>\n\n\n\n<p>Many SDK methods take a reqId parameter, an ID used for debugging and tracing logs. Any number works for the function to run normally, but for easier log tracing and debugging, we recommend making reqId an auto-incrementing static variable, or passing different reqId values to distinguish function calls according to your business needs.<\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"how-to-launch-an-apk-correctly\"><strong><a href=\"#how-to-launch-an-apk-correctly\">How to Launch an APK Correctly<\/a><\/strong><\/p>\n\n\n\n<p>To make sure the APK is correctly authorized by the robot chassis and can use the robot&#8217;s features, launch it from RobotOS Home (see the video below). If you want an APK to launch at boot, simply set &#8220;Boot Apps&#8221; in Settings.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Note: A program run directly from the IDE and opened on the robot has no permissions. It gets permissions only when launched by tapping its icon in the Application Center (Home) or by auto-launch at boot<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video controls src=\"https:\/\/orion-base-test-1256573505.cos.ap-beijing.myqcloud.com\/cn_docs_file\/2021-06-21_17%3A07%3A36_1624266150997464.mp4\"><\/video><\/figure>\n\n\n\n<p class=\"has-medium-font-size\" id=\"faq\"><strong><a href=\"#faq\">FAQ<\/a><\/strong><\/p>\n\n\n\n<p>1. API calls return a resource conflict<\/p>\n\n\n\n<p>For the hardware-related APIs in the SDK, using two APIs to operate the same component at the same time causes a resource conflict. For example, while the robot is navigating, you cannot use the turn-left\/turn-right APIs.<\/p>\n\n\n\n<p>2. Robot screen resolution<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table><tbody><tr><td>GreetingBot<\/td><td>GreetingBot Mini<\/td><td>LuckiBot<\/td><td>BigScreenBot<\/td><\/tr><tr><td>1200&#215;1920<\/td><td>1920&#215;1080<\/td><td>1200&#215;1920<\/td><td>Upper screen 1200&#215;1920<br>Lower screen 1080&#215;1920<\/td><\/tr><\/tbody><\/table><\/figure>\n\n","protected":false},"excerpt":{"rendered":"<p>All Robots Except a Few Older Models Use the Same SDK The robots now share a single, unified SDK, which is included in the demo program. Download the demo program and copy the SDK library file from its libs folder. Sample Code Demo program download: Click to download Note: For the SDK used in the [&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":4,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba\/539\/revisions"}],"predecessor-version":[{"id":963,"href":"https:\/\/doc.orionstar.com\/en\/wp-json\/wp\/v2\/lsvr_kba\/539\/revisions\/963"}],"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}]}}