getCategories
Get categories
POST /v1/game/getCategories
Call initSDK successfully, then complete user authentication before requesting data. The SDK handles authentication headers, signing and encryption. These endpoints require server support.
Method declaration
public static void getCategories(SUDOPCategoryListParams params, SUDOPCategoryListCallback callback);Parameters
params may be null. Defaults are page 0, page size 10 and the server default language.
| Parameter / field | Type | Description |
|---|---|---|
pageNo | int | Zero-based; negative values become 0. |
pageSize | int | Defaults to 10; values <= 0 become 10. |
language | String | Optional BCP 47 tag, such as en-US. null or an empty string uses the server default; the SDK does not substitute the system language. |
Callback and result
public interface SUDOPCategoryListCallback {
void onSuccess(SUDOPCategoryListResult result);
void onFailure(int retCode, String retMsg);
}Callbacks run on the main thread. If callback is null, the method returns without sending a request.
SUDOPCategoryListResult
| Field | Type | Description |
|---|---|---|
pageNo | int | Current zero-based page. |
pageSize | int | Page size. |
total | int | Total number of categories. |
records | List<SUDOPCategoryListItem> | Categories on this page. |
SUDOPCategoryListItem
| Field | Type | Description |
|---|---|---|
code | String | Category code. |
name | Map<String, String> | Localized names keyed by language tag; default is the fallback. |
parentCode | String | Parent category code; maps to parent_code in the response. |
level | int | 1: primary category; 2: secondary category. |
name remains a multilingual map when language is set. Use a non-empty value for the requested language, then fall back to default. Pass the category codes to getGameListByCategory.
Example
Run after initialization and authentication succeed. Replace example category codes with actual values.
SUDOPCategoryListParams params = new SUDOPCategoryListParams();
params.pageNo = 0;
params.pageSize = 20;
params.language = "en-US";
SUDOP.getCategories(params, new SUDOPCategoryListCallback() {
@Override
public void onSuccess(SUDOPCategoryListResult result) {
Log.i("SUDOP", "page=" + result.pageNo + ", total=" + result.total);
for (SUDOPCategoryListItem item : result.records) {
Log.i("SUDOP", "code=" + item.code + ", parentCode=" + item.parentCode + ", level=" + item.level);
}
}
@Override
public void onFailure(int retCode, String retMsg) {
Log.e("SUDOP", "Request failed: " + retCode + ", " + retMsg);
}
});Use the returned pageNo, pageSize and total to determine whether another page is available.
