2017-05-29 07:11:40 +08:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
### 1. Register your APP
|
2025-12-02 20:25:18 +08:00
|
|
|
Register your APP on [IRext SDK console](http://site.irext.net/sdk), (You need to register an IRext account first)
|
2017-05-29 07:11:40 +08:00
|
|
|
|
|
|
|
|
You need to fetch the package name and SHA1 signature of your APP and fill these information as SDK registration information
|
|
|
|
|
|
|
|
|
|
While your APP is registered, you can see the APP key and APP secret in your APP list
|
|
|
|
|
|
|
|
|
|
### 2. Import the SDK
|
2025-11-29 18:36:06 +08:00
|
|
|
Import the Android AAR package by adding following lines to your build.gradle, and sync the gradle configs.
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
implementation 'net.irext.webapi:irext-androidapi:1.5.1'
|
|
|
|
|
```
|
2017-05-29 07:11:40 +08:00
|
|
|
|
|
|
|
|
Add 2 meta-data tags to your AndroidManifest.xml providing APP key and secret get from step 1.
|
|
|
|
|
```xml
|
|
|
|
|
<meta-data
|
2025-12-08 11:06:16 +00:00
|
|
|
android:name="irext_app_key"
|
|
|
|
|
android:value="your app key" />
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 3. Use the SDK
|
|
|
|
|
|
|
|
|
|
Import classes:
|
|
|
|
|
```java
|
2025-11-29 18:36:06 +08:00
|
|
|
import net.irext.webapi.model.*;
|
2017-05-29 07:11:40 +08:00
|
|
|
import net.irext.webapi.WebAPIs;
|
2017-07-04 21:10:46 +08:00
|
|
|
import net.irext.webapi.WebAPICallbacks.*;
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Get web API instance:
|
|
|
|
|
```java
|
|
|
|
|
WebAPIs webApis = WebAPIs.getInstance();
|
|
|
|
|
```
|
|
|
|
|
Sign in for access id and token:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
SignInCallback signInCallback = new SignInCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSignInSuccess(UserApp userApp) {
|
|
|
|
|
int id = userApp.getId();
|
|
|
|
|
int token = userApp.getToken();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSignInFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSignInError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
webApis.signIn(context, signInCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Fetch household appliances categories:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
ListCategoriesCallback listCategoriesCallback = new ListCategoriesCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onListCategoriesSuccess(List<Category> categories) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListCategoriesFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListCategoriesError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
webApis.listCategories(listCategoriesCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Fetch brands of a certain category other than STB:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
ListBrandsCallback listBrandsCallback = new ListBrandsCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onListBrandsSuccess(List<Brand> brands) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListBrandsFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListBrandsError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-07-04 21:11:34 +08:00
|
|
|
webApis.listBrands(category.getId(), listBrandsCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Fetch cities (in China) for STB:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
ListProvincesCallback listProvincesCallback = new ListProvincesCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onListProvincesSuccess(List<City> provinces) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListProvincesFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListProvincesError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ListCitiesCallback listCitiesCallback = new ListCitiesCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onListCitiesSuccess(List<City> cities) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListCitiesFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListCitiesError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
webApis.listProvinces(listProvincesCallback);
|
|
|
|
|
webApis.listCities(provincePrefix, listCitiesCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Fetch STB operators of a certain city:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
ListOperatersCallback listOperatorCallback = new ListOperatersCallback() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListOperatorsSuccess(List<StbOperator> operators) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListOperatorsFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListOperatorsError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
webApis.listOperators(cityCode, listOperatorCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Fetch remote indexes of a certain brand or STB operator:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
ListIndexesCallback listIndexesCallback = new ListIndexesCallback() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListIndexesSuccess(List<RemoteIndex> indexes) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListIndexesFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onListIndexesError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
webApis.listRemoteIndexes(category.getId(), brand.getId(), city.getCode(), operator.getOperator_id(), listIndexesCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|
|
|
|
|
Download IR binary for certain remote index:
|
|
|
|
|
```java
|
2017-07-04 21:09:56 +08:00
|
|
|
DownloadBinCallback downloadBinCallback = new DownloadBinCallback() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDownloadBinSuccess(InputStream inputStream) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDownloadBinFailed() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDownloadBinError() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
webApis.downloadBin(remoteIndex.getRemote_map(), remoteIndex.getId(), downloadBinCallback);
|
2017-05-29 07:11:40 +08:00
|
|
|
```
|