CXR-L(EN)
CXR-L(EN)
IntroductionQuick StartDevelopment Flow & State-MachineTerms and Abbreviations
Feature Development
Version HistoryAndroid
iOS
cxr-l-sdk · v1.0.1 · snapshot 2026-05-13· ↗ source
Authentication
Android: Authentication
Scenario
Before calling CXRLink.connect(token), you must complete an OAuth-like authorization via Rokid AI App to obtain the communication token. CXRLSample uses AuthorizationHelper provided by Rokid AI App to start and parse the authorization.
Prerequisites
- Rokid AI App is installed on the phone (refer to
MainViewModel.checkRokidAIAppInstalled). - You have completed “SDK Import”.
Key APIs (Sample)
| Step | API / type | Description |
|---|---|---|
| Check installation | AuthorizationHelper.INSTANCE.isRequiredRokidAppInstalled(Activity) | Determines whether the home page shows branches such as “go install”. |
| Start authorization | AuthorizationHelper.INSTANCE.requestAuthorization(Activity, requestCode) | Opens the authorization UI; requestCode should match onActivityResult. |
| Parse result | AuthorizationHelper.INSTANCE.parseAuthorizationResult(requestCode, Intent?) | Returns an AuthResult subtype. |
Typical AuthResult branches (see MainViewModel.checkAuthorizationResult):
AuthResult.AuthSuccess: readtokenand mark as authorized.AuthResult.AuthFail: failure; clear token.- Others (e.g., cancel): treated as unauthorized per Sample logic.
Activity callback
Override onActivityResult in the host Activity (the Sample uses MainActivity):
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == CONSTANT.AUTH_REQUEST_CODE) {
viewModel.checkAuthorizationResult(resultCode, data)
}
}
Note: the Sample passes resultCode as the first parameter of parseAuthorizationResult and aligns with the comment “matches what the current SDK parser expects”. When integrating, do not arbitrarily swap it to requestCode unless you have verified the SDK version’s expectation.
Constraints
- When unauthorized, do not assume
connectwill succeed. - Authorization UI is hosted by Rokid AI App; your app only performs redirection and result parsing.
Sample reference paths
com.rokid.cxrlsample.activities.main.MainActivitycom.rokid.cxrlsample.activities.main.MainViewModelcom.rokid.cxrlsample.dataBean.CONSTANT.AUTH_REQUEST_CODE