Skip to content

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 ​

java
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 / fieldTypeDescription
pageNointZero-based; negative values become 0.
pageSizeintDefaults to 10; values <= 0 become 10.
languageStringOptional 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 ​

java
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 ​

FieldTypeDescription
pageNointCurrent zero-based page.
pageSizeintPage size.
totalintTotal number of categories.
recordsList<SUDOPCategoryListItem>Categories on this page.

SUDOPCategoryListItem ​

FieldTypeDescription
codeStringCategory code.
nameMap<String, String>Localized names keyed by language tag; default is the fallback.
parentCodeStringParent category code; maps to parent_code in the response.
levelint1: 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.

java
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.