Skip to content
yangfengbang edited this page May 5, 2022 · 9 revisions

See the Chinese Guide

1. Get Started

This guide is intended for publishers who want to integrate the AntiAddictionSystem.

1.1 Prerequisites

OS: Windows, Mac, Linux
Android SDK: > 4.4(API level 19)
IDE: Eclipse with ADT (ADT version 23.0.4) OR Android-Studio
Java: > JDK 7

2. Import the AntiAddictionSystem SDK

2.1 Android studio

add AntiAddictionSystem SDK adapters dependencies.

dependencies {
    // AntiAddictionSDK
    implementation "io.github.yumimobi:antiaddiction:1.1.9"

add maven central in project build.gradle

allprojects {
    repositories {
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
}

2.3 Proguard

If your project turn on minifyEnabled, add the following to the proguard file.

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,Synthetic,EnclosingMethod
-keep class com.android.antiaddiction.** { *;}

3. Configure the parameters required for AntiAddictionSystem SDK

3.1 Download ZplayConfig.xml and add to you project assets

image

Download ZplayConfig.xml

3.2 Configure the ZplayConfig.xml

image

For the GameID, ChannelID parameters in the ZplayConfig.xml file, please contact Zplay products

4 Integration

4.1 Init AntiAddictionSDK

 AntiAddictionSystemSDK.init(Activity, new AntiAddictionCallback() {
            @Override
            public void onTouristsModeLoginSuccess(String touristsID) {
                //tourist login result (Automatic login is implemented by SDK)
                //tourist login success
            }

            @Override
            public void onTouristsModeLoginFailed() {
                //tourist login result (Automatic login is implemented by SDK)
                //tourist login failed
            }

             @Override
            public void realNameAuthenticateSuccess() {
                //real name auth success
            }

            @Override
            public void realNameAuthenticateFailed() {
                //real name auth failed
            }

             @Override
            public void noTimeLeftWithTouristsMode() {
                // tourist's time is ran out
                // will display real name auth controller after 3 seconds
            }

            @Override
            public void noTimeLeftWithNonageMode() {
                // game time is ran out
                // will display the game time is ran out alert-controller after 3 
            }

            @Override
            public void onClickExitGameButton() {
                // The user clicks the exit game button on the real-name authentication interface, and the user clicks to exit the game
            }

            @Override
            public void onClickTempLeaveButton() {
                //The user clicks the temporary non-authentication button on the real-name authentication interface
            }

            @Override
            public void onCurrentUserInfo(long leftTime, boolean isAuth, AgeGroup ageGroup) {
                 // Callback current user info
                 // leftTime: remaining playable time,-1 means adult, unlimited

                 // isAuth:
                 // true:has real-name authentication
                 // false:not real-name authentication

                 // ageGroup: 
                 // AgeGroup.unknown: not real-name authentication
                 // AgeGroup.adult: adult
                 // AgeGroup.nonage: nonage

                  //if leftTime = 0 and isAuth = false,please show Real-name authentication by 4.3.2 interface
                 
            }

            @Override
            public void onCurrentUserCanPay() {
                //user can pay
            }

            @Override
            public void onCurrentUserBanPay() {
                //user not can pay
            }

            @Override
            public void onCurrentChannelUserInfo(AgeGroup ageGroup) {
                //current huawei, lenovo channel user age groupinfo
                 
                 // ageGroup: 
                 // AgeGroup.unknown: not real-name authentication
                 // AgeGroup.adult: adult
                 // AgeGroup.nonage: nonage
            }
        });

4.2 Show the remaining time reminder for tourists and minors

Every time you enter the main interface of the game, show the online time reminder interface for tourists and minor users This interface is called by the game after initialization. It is necessary to determine that the SDK is logged in. If the SDK is not logged in, it will be called in the callback of successful SDK login. Adults do not need to show this interface.

 if (AntiAddictionSystemSDK.isLogined(this)) {
    AntiAddictionSystemSDK.showAlertInfoDialog(this);
 }

4.3 Real-name authentication interface

4.3.1 Show Real-name authentication in the tourist mode (Users can click not to authenticate)

If the user clicks on the real-name authentication function on the main interface of the game,You can show the Real-name auth view by following interface.

AntiAddictionSystemSDK.showRealNameDialog(Activity);

4.3.2 Show Real-name authentication in the tourist mode (Users can't click not to authenticate,only can click exit game)

scenes to be used: If the user clicks to exit the game, the developer needs to display the real-name authentication obtaining reward interface in onClickExitGameButton(); this callback (this interface is implemented by the developer), this interface provides two interactive buttons. Quit game button: Click this button to quit the game. Real-name authentication button: Click this button to show the real-name authentication interface provided by the SDK again.

AntiAddictionSystemSDK.showForceExitRealNameDialog(Activity);

4.4 Set the channel UserId interface (required for Huawei and Lenovo channels)

In order to be compatible with Huawei, Lenovo’s channel login and payment SDK is compatible with real-name authentication. The game needs to call the following interface to set the channel UserId after Huawei Lenovo logs in.

Note: Huawei and Lenovo channel anti-addiction function will only be activated after calling the interface below, otherwise it will not activate any function of the anti-addiction SDK

//userId:User ID returned by Huawei and Lenovo channel login SDK
AntiAddictionSystemSDK.setChannelUserId(Activity, userId);

4.5 Other API

4.5.1 Application will enter background(Required)

When the user presses the home button to exit the game to the background, please call the following interface

Warning: Call the following api when application will enter background.Not calling will cause the anti-addiction SDK to calculate the game time error
AntiAddictionSystemSDK.onPause();

4.5.2 Application will enter foreground(Required)

Warning: Call the following api when application will enter foreground.Not calling will cause the anti-addiction SDK to calculate the game time error
AntiAddictionSystemSDK.onResume();

4.5.3 Get the tourists mode login status interface (Optional)

//true:has login
//false:not login
boolean isLogined = AntiAddictionSystemSDK.isLogined(Activity);

4.5.4 Check user authentication status(Optional)

//get authentication status
//true: authentication success
//false: not authentication
boolean isAuthenticated = AntiAddictionSystemSDK.isAuthenticated(Activity);

4.5.5 Check user is adult(Optional)

// AgeGroup.unknown: unknown
// AgeGroup.adult: adult
// AgeGroup.nonage: nonage
AgeGroup ageGroup = AntiAddictionSystemSDK.isAdult(Activity);

4.5.6 Get user left time (Optional)

//-1:user is an adult and is not restricted
//Greater than 0:The user's remaining playable time, in seconds
long leftTimeOfCurrentUser = AntiAddictionSystemSDK.leftTimeOfCurrentUser(Activity)

4.5.7 Show view details interface (Optional)

This interface displays the relevant rules of the Central Propaganda Department on the anti-addiction policy

AntiAddictionSystemSDK.showTimeTipsDialog(Activity);

4.5.8 Detect consumption limit (Optional)

Not logged in and minors cannot pay in the game, and the consumption restriction interface will be displayed. No limit for adults

AntiAddictionSystemSDK.checkCurrentUserPay(Activity);