Current Path:Home » Documents » API Docs » The text

Coraool Android SDK Development Guide

1. Integration process

1.1 Introduction of SDK

Copy the sdk to the directory of the application , and add the dependency of the aar package in libsthe corresponding module.build.gradle

implementation files("libs/coraool-android-sdk-1.1.2-beta.aar")
VersionDateRelease NotesSDK
202402201. bp data update
2. Official version 1.0.8
coraool-android-sdk-1.0.8.aar_ Download
202402281. Added CoraoolJsBridge to support H5 adjustment of Native buried points
2. Standardized Tracking data dictionary
coraool-android-sdk-1.0.9-beta.aar_ Download
202404131. Add pageId tracking
2. Bugfix the field location where buried parameters are saved
3. jsbridge is compatible with the upper and lower case of eventType values
​​4. jsbridge obtains buried verification information
coraool-android-sdk-1.1.1-beta.aar_ Download
202405051. Add zip request compression to reduce network trafficcoraool-android-sdk-1.1.2-beta.aar_ Download

1.2 Configure SDK

1.2.1 Permission Grant

PermissionsPermission usage
ACCESS_NETWORK_STATEDetect the networking method, avoid data transmission when the network is abnormal, and save traffic and power.
INTERNETAllows the application to network and send statistical data in order to provide statistical analysis services.
ACCESS_FINE_LOCATION (optional)By obtaining location information, it provides developers with anti-cheating functions and eliminates cheating devices; at the same time, it corrects users’ geographical distribution data to make report data more accurate.
ACCESS_COARSE_LOCATION (optional)By obtaining location information, it provides developers with anti-cheating functions and eliminates cheating devices; at the same time, it corrects users’ geographical distribution data to make report data more accurate.
<uses-sdk android:minSdkVersion="8"></uses-sdk>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

1.2.2 Configuration confusion

If your application uses code obfuscation, please add the following configuration to prevent the SDK from being mistakenly obfuscated.

-keep class com.coraool.** { *; }
-keepclassmembers class * {
   public <init> (org.json.JSONObject);
}

1.3 Initialization steps

1.3.1 Apply for AK

Before accessing each app, you need to apply for AppId, AppKey, and AppSecret.

1.3.2 SDK initialization

The interface class name provided by the SDK to the outside world is called com.coraool.CoraoolLib, and all methods provide services to the outside world through this class.

First, in the onCreate method of Application, use the Token allocated by Coraool to initialize the SDK:

/**
 * Call this method to initialize Coraool SDK when launch the application.
 *
 * @param application   application object
 * @param paramProvider interface
 */
public void initialize(Application application, IParamProvider paramProvider);

Initialization example:

public class CApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        CoraoolLib.getInstance().initialize(this, new IParamProvider() {
            @Override
            public String getAppId() {
                return "appId";    // 目前传测试值,后续在coraool申请
            }

            @Override
            public String getAppKey() {
                return "appKey";    // 目前传测试值,后续在coraool申请
            }

            @Override
            public String getAppSec() {
                return "appSec";    // 目前传测试值,后续在coraool申请
            }

            @Override
            public boolean isEnableLog() {
                return true;=
            }
        });
        CoraoolLib.getInstance().setPageCollectionMode(CoraoolLibConst.PageMode.Auto);
    }
}

1.4 Other APIs

1.4.1 Login user ID

When users log in and log out, their login information needs to be updated in real time.

/**
 * Call this api to update the login account whenever login, logout or switch account.
 *
 * @param userId login user id
 */
public void setUserId(String userId);

1.4.2 Log switch

During the development stage, it is recommended to turn on the log switch to facilitate checking the key processes of the SDK and managing the contents of the log. Please turn off this switch before publishing online to avoid log printing affecting APP performance.

/**
 * Turn on this switch in DEBUG mode to trace sdk logs in different levels.
 * Turn it off before publishing app to ensure better performance in production situation.
 *
 * @param enableLog switch
 */
public void setEnableLog(boolean enableLog);

1.4.3 Strict mode

It is recommended to turn on the debug mode during the development stage to check whether the use of various hidden parameters is reasonable. Please close it before publishing online to ensure the stability of the App.

/**
 * Enable [StrictMode] will check all api criteria while running and throw errors if wrong.
 * It is recommended to turn on strict mode in DEBUG mode and turn it off before publish.
 * This will make sure all usages are correct and make the data engineering easier.
 *
 * @param strictMode default false
 */
public void setStrictMode(boolean strictMode);

2. Buried interface

2.1 Tracking buried points

2.2.1 Buried point submission

Interface definition

public TrackBuilder(String eventName);

public void track(Map<String, Object> eventData);

Parameter Description:

parameterexplainillustrate
logMapBuried point data mapIt is not recommended to manually construct buried point data constructed through TrackBuilder subclasses, as it is prone to errors.

2.1.2 Control buried points

TrackBuilder builder = new TrackControlBuilder(String eventName)
                            .setProperties(Map<String, Object> properties)
                            .setProperty("业务参数key1", 2.01)
                            .setProperty("业务参数key2", "业务参数value2");
CoraoolLib.getInstance().track(builder.build());
FieldtypeIs it necessaryexplainillustrate
eventNamestringyesevent nameIdentify where the user is on the page
propertiesMap<String, Object>noevent parametersBusiness parameters associated with the current event, used for offline analysis
property_keystringnoevent parameter keyBusiness parameters associated with the current event, used for offline analysis
property_valuestringnoevent parameter valueBusiness parameters associated with the current event, used for offline analysis

2.1.3 Exposure and buried points

TrackBuilder builder = new TrackExposeBuilder(String eventName)
                            .setProperties(Map<String, Object> properties)
                            .setProperty("业务参数key1", "业务参数value1")
                            .setProperty("业务参数key2", "业务参数value2");
CoraoolLib.getInstance().track(builder.build());
FieldtypeIs it necessaryexplainillustrate
eventNamestringyesevent nameIdentify where the user is on the page
propertiesMap<String, Object>noevent parametersBusiness parameters associated with the current event, used for offline analysis
property_keystringnoevent parameter keyBusiness parameters associated with the current event, used for offline analysis
property_valuestringnoevent parameter valueBusiness parameters associated with the current event, used for offline analysis

2.1.4 Custom buried points

TrackBuilder builder = new TrackCustomBuilder(String eventName)
                            .setPageName(String pageName);
                            .setProperties(Map<String, Object> properties)
                            .setProperty("业务参数key1", "业务参数value1")
                            .setProperty("业务参数key2", "业务参数value2");
Coraool.getInstance().track(builder.build());
FieldtypeIs it necessaryexplainillustrate
eventNamestringyesevent nameIdentify where the user is on the page
eventPagestringyesEvent related pageCustom buried points must also specify associated page parameters.
propertiesMap<String, Object>noevent parametersBusiness parameters associated with the current event, used for offline analysis
property_keystringnoBusiness parameter keyBusiness parameters associated with the current event, used for offline analysis
property_valuestringnoBusiness parameter valueBusiness parameters associated with the current event, used for offline analysis

2.1.5 Page burying points

2.1.5.1 Event timing

https://corp.coraoolstatic.com/wp-content/uploads/2024/03/time sequence-1024x630.png

2.1.5.2 Collection mode

Interface definition

public void setPageCollectionMode(int mode);

Parameter Description:

parameterexplainillustrate
modeHow to collect page eventsCoraoolLibConst.PageMode.Manual Manual (default mode) CoraoolLibConst.PageMode.AUTO Automatic

Sample code

// 自动采集选择:仅支持采集activity,在使用AUTO模式时,可以叠加手动模式,实现方式看#自动埋点API
CoraoolLib.getInstance().setPageCollectionMode(CoraoolLibConst.PageMode.AUTO);

//手动采集选择:支持activity和非activity,默认手动
CoraoolLib.getInstance().setPageCollectionMode(CoraoolLibConst.PageMode.Manual);

2.1.5.3 Automatically bury points

Interface definition

1. 增加页面事件的埋点参数

public void updatePageProperties(Object pageObject, Map<String, Object> props);

2. 自定义页面名称

public void updatePageName(Object pageObject, String name);

3. 跳过当前页面的埋点

public void skipPage(Object pageObject);

Parameter Description:

method nameparameterexplainillustrate
updatePagePropertiespageObjectPage Activity object
propsUpdate parametersApplies only to current page
updatePageNamepageObjectPage Activity object
nameCustom page nameThe SDK takes the class name of pageObject by default, eg getSimpleName()
skipPagepageObjectPage Activity objectSkip the hidden page of the specified page in automatic mode

Sample code

/**
 * 添加页面事件的参数,仅对当前页面实例生效
 * 页面参数保存在内存Map中,key为页面对象的simpleName+hashCode
 */
CoraoolLib.getInstance().updatePageProperties(Object pageObject, Map<String, Object> props);

/**
 * 默认的页面名称是Class.SimpleName,可以自定义页面名称
 */
CoraoolLib.getInstance().updatePageName(Object pageObject, String name);

/**
 * 个别页面不需要打点的,在Activity.onCreate()函数关掉当前页面打点,而不会影响全局的打点
 * 当前页面关闭自动模式后,仍然可以用下面的手动模式进行打点
 */
CoraoolLib.getInstance().skipTrackPage(Object pageObject)

2.1.5.4 Manual buried points

Interface definition

1. 页面展现的时候调用(onResume)

public void trackPageStart(Object pageObject, String pageName);

2. 页面退出的时候调用(onPause)

public void trackPageEnd(Object pageObject, String pageName);

Parameter Description:

method nameparameterexplainillustrate
trackPageStartpageObjectPage Activity object
pageNameCustom page name
trackPageEndpageObjectPage Activity object
pageNameCustom page name
/**
 * 页面展现的时候调用(onResume)
 */
protected void onResume() {
    super.onResume();
    CoraoolLib.getInstance().trackPageStart(homeActivity, String pageName);
}

/**
 * 页面退出的时候调用(onPause)
 */
protected void onPause() {
    super.onPause();
    CoraoolLib.getInstance().trackPageEnd(Object pageObjet, String pageName);
}

2.2 GTX burying protocol

2.2.1 GTP/GTC traffic tracking

GTX buried points are used to track and analyze page traffic, and can solve the following key business problems:

  • Statistics of basic indicators such as PV and UV of the specified page;
  • Track the source and destination of page traffic and analyze the traffic funnel of user paths;
  • Based on traffic and conversion evaluation, inform the business side of the traffic efficiency of each page and the pit within the page;

  Glossary:

  • Global Tracking Position (GTP): Global position tracking model, used to track locations and the flow of traffic between different locations;
  • Global Tracking Content (GTC): Global content tracking model, used to track delivery content and guide conversion efficiency;
  • Global Tracking X (GTX): refers to the solution composed of GTP and GTC;

2.2.1.1 GTP parameter definition

GTP parameter definition: a.b.c.d = ${appId}.${pageId}.${module}.${point}, GTP needs to be constructed and used strictly in accordance with the following specifications. The UI layer constructs the four-layer structure through structured data (this method is recommended), or it can be constructed manually.

GTPmeaningillustrate
a position${appId}Different terminals are allocated independently, corresponding to the appId of the SDK initialization parameter, which is globally unique.
b position${pageId}Specified and applied for by the product, unique in the current ${app}, b bit maintained by the access party, registered through documents or the system
c position${moduleId}The floor or block number of the page, unique within the current page ${pageId}
d position${pointId}The subdivided point number within the floor is unique within the current module ${moduleId}
https://corp.coraoolstatic.com/wp-content/uploads/2024/01/gtp-1024x670.png

2.2.1.2 GTC parameter definition

GTC parameter definition: a.b.c.d = ${sysId}.${algoId}.${algoVer}.${audienceId}, GTC also contains a 4-layer structure, definitions at different levels

GTCmeaningillustrate
a position${sysId}Delivery system ID, used to identify different content delivery parties
b position${algoId}Delivery algorithm ID, used to identify the delivery algorithm used by the delivery system to generate different content
c position${algoVer}Delivery algorithm version ID, used to identify different versions of the delivery algorithm
d position${audienceId}The placement group ID is used to identify different placement groups.

2.2.1.3 Principle introduction

According to the definitions of GTP and GTC above, assume the following scenario: There are three pages in an APP. In order to track the traffic funnel and delivery guidance effect of the three pages, we encode the click hot spots of the page according to the GTP model. :

https://corp.coraoolstatic.com/wp-content/uploads/2024/03/Principle Introduction-1024x243.png
  • Home page red block code:
    • gtp=a1024.home.top.0: a1024 is the unique code of the APP, home is the home page name, top is the top banner floor, and 0 represents the first image.
    • gtc=dly.alg1.v2.r30: dly represents the delivery system code, alg1 represents algorithm 1, v2 represents the algorithm version, and r30 represents newly registered users within 30 days.
  • List page block encoding:
    • gtp=a1024.list.hot.2: a1024 is the unique code of the APP, list is the name of the list page, top is the hot-selling floor, and 2 means the second resource position
    • gtc=dly.alg2.v1.r30: dly represents the delivery system code, alg2 represents algorithm 2, v1 represents algorithm version, r30 represents newly registered users within 30 days

After the user enters the Home page, click the red area to jump to the List page. In order for the List page to be able to count that the current jump source is the Home page, the Home page needs to pass the source information through the gtp and gtc parameters during the jump process. List page, after receiving the gtp and gtc parameters from the Home page, the List page will automatically parse these two parameters and record them in the page event. The List page jumps to the Detail page in the same way.

The method of passing parameters needs to be agreed upon in advance. There are two methods of passing parameters for Activity in the Android system:

  • Method 1: Intent#putExtra(key, value)Passed through, suitable for front-end hard-coded components;
  • Method 2: Intent#setData(Uri)Passed through, suitable for back-end delivery links;

CoraoolSDK uses these two parameter transmission methods at the same time. When the two conflict with each other, based on the priority comparison, Intent#putExtra(key, value) will be used first, because we believe that this method is used after the access party fully understands the meaning and usage of the fields. It was set up this way intentionally;

2.2.2 Buried point access

You need to understand several key timings for hidden access:

  • When the page is onResume: You need to add the GTP encoding of the current page to the page event through the updatePageProperties interface. After the page event is reported, you can know the name of the current page under the GTP protocol. Because of the current page identified, gtp only needs to contain the a bit and b bit, and the c/d bit can be set to 0 or not passed (for example: a1024.home.0.0 or a1024.home)
  • Prepare parameters before jumping: Before jumping, you need to add the encoding of the click position to Intent#Extra or Intent#Data according to the GTP and GTC protocols so that it can be passed to the next page;

2.2.2.1 Activity@See

  • viaIntent#putExtra
/** 
 * 备注:接入方的App通过定义接口 IPageTrack,可以规范各个页面获取名称的方式
 */
public class HomePageActivity extends AppCompatActivity implements IPageTrack {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_track_kwd_page);
        
        findViewById(R.id.goto_page_srp).setOnClickListener(v -> {
            // 跳转前:通过Extra的方式传参  
            Intent intent = new Intent(HomePageActivity.this, ListPageActivity.class);
            intent.putExtra(CoraoolLibConst.KEY_GTP, String.format("a1024.%s.1.0", getPageName()));
            intent.putExtra(CoraoolLibConst.KEY_GTC, "dly.alg1.v2.r30");
            HomePageActivity.this.startActivity(intent);
        });
    
    @Override
    protected void onResume() {
        super.onResume();
        // 页面启动时:把当前页面的 gtp 编码记录到当前页的页面事件中
        CoraoolLib.getInstance().updatePageProperties(this, new HashMap<String, Object>() {{
            put(CoraoolLibConst.KEY_GTP, String.format("a1024.%s.0.0", getPageName()));
        }});
    }
    
    @Override
    public String getPageName() {
        return "home"
    }
}
  • viaIntent#setData
/** 
 * 备注:接入方的App通过定义接口 IPageTrack,可以规范各个页面获取名称的方式
 */
public class HomePageActivity extends AppCompatActivity implements IPageTrack {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_track_kwd_page);
        
        findViewById(R.id.goto_page_srp).setOnClickListener(v -> {
            // 跳转前:通过Uri的方式传参            
            Uri uri = Uri.parse("protocol://your.uri?k1=v1&k2=v2").buildUpon()
                    .appendQueryParameter(CoraoolLibConst.KEY_GTP, String.format("a1024.%s.1.0", getPageName()))
                    .appendQueryParameter(CoraoolLibConst.KEY_GTC, "dly.alg1.v2.r30")
                    .build();
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        });
    
    @Override
    protected void onResume() {
        super.onResume();
        // 页面启动时:把当前页面的 gtp 编码记录到当前页的页面事件中
        CoraoolLib.getInstance().updatePageProperties(this, new HashMap<String, Object>() {{
            put(CoraoolLibConst.KEY_GTP, String.format("a1024.%s.0.0", getPageName()));
        }});
    }
    
    @Override
    public String getPageName() {
        return "home"
    }
}

2.2.3 Example description

2.2.3.1 Forward and backward

2.2.3.2 Switching between front and back

https://corp.coraoolstatic.com/wp-content/uploads/2024/03/Switching between front and back.png

2.2.3.3 Switching between front and back

https://corp.coraoolstatic.com/wp-content/uploads/2024/03/Some pages are hidden.png

3. Invoke API interface

Coraool SDK provides API-based data services and defines a set of universal and caller-friendly interfaces. Invoke interface calls initiated through Coraool SDK usually include the following four steps:

3.1 Construct Response

com.coraool.CoraoolResponseIt is an encapsulation of the Coraool API protocol and contains 3 fields. If you don’t care about the result of the request, you can just receive the request result directly; if there is business data that needs to be processed, you need to inherit this class, add the result field, and provide Getter and setter methods, according to the agreement of the Coraool API protocol, the business parameters returned by the API call will be stored in this Map structure. The SDK will automatically deserialize it to facilitate direct use by the application layer.

Parameter Description:

parametertypeexplainillustrate
successbooleanIs this request successful?The returned result is valid if and only if this field is true
codeinterror code200 means success, other values ​​are similar to the definition of http status. If a negative number is returned, it means that an exception occurred in the SDK itself. The specific error code CoraoolResponseis defined by the constant
messagestringText description of the request resultIt is only used to assist in troubleshooting the request process and cannot be used to judge business logic. It is always returned when the request is successful "SUCCESS". If an error or exception occurs in the request, the corresponding error description information is returned, which can be used for troubleshooting or feedback to technical support;
resultanyCustom business data typesIf you need to pay attention to the result of the request, according to the Coraool API protocol, the data will be stored in a JSON object with result as the key.

Sample code:

public class CoraoolRankingResponse extends CoraoolResponse {

    // RankingData表示具体的业务数据
    public RankingData result;
    
    public RankingData getResult() {
        return result;
    }
    
    public void setResult(RankingData result) {
        this.result = result;
    }
}

public class RankingData {
    public JSONArray ranking;
    public JSONObject track;
    public String version;
}

3.2 Construct Request

Construct request parameters that conform to the Coraool API protocol by creating an object of CoraoolRequest type.

Parameter Description:

parametertypeexplainillustrate
apiNamestringInterface nameBusiness interface registered on Coraool open API, for exampleopen.coraool.bingoplus.home.game.ranking
apiVersionstringInterface versionBusiness version registered on Coraool open API, e.g.1.0.0
dataanyRequest parametersSpecific request parameter object
connectTimeoutintLink timeout in millisecondsNetwork connection timed out
readTimeoutintRead timeout in millisecondsReturn data stream read timeout
callbackOnMainThreadbooleanCallback to the main thread switchWhether to call back to the UI main thread, the default is true. For data that is not directly displayed, it is recommended to set it to false, so that the request can be called back to the background thread to facilitate secondary processing of the data.

Sample code:

CoraoolRequest request = new CoraoolRequest();
request.setApiName("open.coraool.bingoplus.home.game.ranking");
request.setApiVersion("1.0.0");
request.setCallbackOnMainThread(true);
request.setReadTimeout(3 * 1000);
request.setData(new HashMap<String, Object>(){{
    put("userId", "登录用户ID");
    put("afId", "appsFlyer的ID");
    put("deviceId", "设备ID");
}});

3.3 Initiate a request

The request API of the SDK is divided into synchronous requests and asynchronous requests, which are uniformly encapsulated under the interface class of CoraoolLib

3.3.1 Synchronous request

Interface definition:

/**
 * Send a coraool request synchronously.
 *
 * @param clz Response class type
 * @param request request complies with coraool api protocol
 * @return response complies with coraool api protocol
 * @param <T> { body }
 */
public <T extends CoraoolResponse> T syncInvoke(Class<T> clz, 
                                                CoraoolRequest request)

/**
 * Send a request synchronously. If the callback interface is provided,
 * the interface will be invoked before this method returns.
 *
 * @param clz Response class type
 * @param request request complies with coraool api protocol
 * @param callback callback when done
 * @return response complies with coraool api protocol
 * @param <T> { body }
 */
public <T extends CoraoolResponse> T syncInvoke(Class<T> clz, 
                                                CoraoolRequest request, 
                                                CoraoolNetCallback<T> callback)

Parameter Description:

parameter nametypeexplainillustrate
clzClass<T>Returns the Class of the object classClass corresponding to the Response object class in the first step
requestCoraoolRequestRequest parametersCorresponding to the second step request parameter object
callbackCoraoolNetCallback<T>CallbackCallbackIf the Callback interface parameter is provided, this request will always call back to a method in the Callback interface. For the definition of the interface method, see the next step.

Return value description:

return valuetypeexplainillustrate
response<T extends CoraoolResponse>Return object classThe object instance corresponding to the first step Response will be null only when the object cannot be instantiated by reflection, so the parameterless constructor must be retained.

Example description:

private void syncRequest() {
    CoraoolRequest request = new CoraoolRequest();
    request.setApiName("open.coraool.bingoplus.home.game.ranking");
    request.setApiVersion("1.0.0");
    request.setData(new HashMap<String, Object>(){{
        put("userId", "123");
        put("afId", "afIdx");
        put("deviceId", "devicedevice");
    }});
    
    CoraoolRankingResponse response = CoraoolLib.getInstance()
            .syncInvoke(CoraoolRankingResponse.class, request);
}

3.3.2 Asynchronous requests

Interface definition:

/**
 * Send a request asynchronously. If the callback interface is provided,
 * the interface will be invoked before this method returns.
 *
 * @param clz Response class type
 * @param request request complies with coraool api protocol
 * @param <T> { body }
 */
public <T extends CoraoolResponse> void asyncInvoke(Class<T> clz,
                                                    CoraoolRequest request)
                                              
/**
 * Send a request asynchronously. If the callback interface is provided,
 * the interface will be invoked before this method returns.
 *
 * @param clz Response class type
 * @param request request complies with coraool api protocol
 * @param callback callback when done
 * @param <T> { body }
 */
public <T extends CoraoolResponse> void asyncInvoke(Class<T> clz, 
                                                    CoraoolRequest request, 
                                                    CoraoolNetCallback<T> callback)

Parameter Description:

parameter nametypeexplainillustrate
clzClass<T>Returns the Class of the object classClass corresponding to the Response object class in the first step
requestCoraoolRequestRequest parametersCorresponding to the second step request parameter object
callbackCoraoolNetCallback<T>CallbackCallbackIf the Callback interface parameter is provided, this request will always call back to a method in the Callback interface. For the definition of the interface method, see the next step.

Example description:

private void asyncRequest() {
    CoraoolRequest request = new CoraoolRequest();
    request.setApiName("open.coraool.bingoplus.home.game.ranking");
    request.setApiVersion("1.0.0");
    request.setCallbackOnMainThread(true);
    request.setReadTimeout(5 * 1000);
    request.setData(new HashMap<String, Object>(){{
        put("userId", "123");
        put("afId", "afIdx");
        put("deviceId", "devicedevice");
    }});
    
    CoraoolLib.getInstance().asyncInvoke(CoraoolRankingResponse.class, request, new CoraoolNetCallback<CoraoolRankingResponse>() {
        @Override
        public void onSuccess(CoraoolRankingResponse response) {
            Log.e("TAG", "Success: " + JSON.toJSONString(response));
        }

        @Override
        public void onFailed(int code, String message) {
            Log.e("TAG", String.format("Failed: code=%d, message=%s", code, message));
        }

        @Override
        public void onSystemError(int code, String message) {
            Log.e("TAG", String.format("Error: code=%d, message=%s", code, message));
        }
    });
}

3.4 Interface callback

Interface callbacks are used to receive correct and abnormal results

interfaceparametertypeexplainillustrate
onSuccessresponseTReturn object typeReturned when the request is processed correctly, corresponding to success=true
onFailedcodeintRequest error codeCorresponds to the scenario of success=false, if the signature is wrong, invalid token, etc.
messagestringwrong description
onSystemErrorcodeintRequest error codeVarious system errors, such as network disconnection, authorization errors, data parsing exceptions, etc.
messagestringwrong description
public interface CoraoolNetCallback<T> {

    /**
     * Totally success including network and business
     *
     * @param response response body {@link CoraoolResponse}
     */
    void onSuccess(T response);

    /**
     * Send request successfully but the response data contains business error, like
     * invalid appKey, signature mismatch, params illegal and so on.
     *
     * @param code error reason code leverages http status definition
     * @param message plaintext explaining the error reason.
     */
    void onFailed(int code, String message);

    /**
     * Errors like network not connected, auth error, protocol error and so on
     *
     * @param code {@link CoraoolLibConst}
     * @param message plaintext explaining the error reason.
     */
    void onSystemError(int code, String message);
}
Not allow to forward/copy without permission:CORAOOL » Coraool Android SDK Development Guide
Share to
0 Likes

Recomm

Comments (0)

Contact us