-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This guide is intended for publishers who want to integrate the AntiAddictionSystem.
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
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/' }
}
}
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.** { *;}
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
}
});
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);
}
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);
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);
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 errorAntiAddictionSystemSDK.onPause();
AntiAddictionSystemSDK.onResume();
//true:has login
//false:not login
boolean isLogined = AntiAddictionSystemSDK.isLogined(Activity);
//get authentication status
//true: authentication success
//false: not authentication
boolean isAuthenticated = AntiAddictionSystemSDK.isAuthenticated(Activity);
// AgeGroup.unknown: unknown
// AgeGroup.adult: adult
// AgeGroup.nonage: nonage
AgeGroup ageGroup = AntiAddictionSystemSDK.isAdult(Activity);
//-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)
This interface displays the relevant rules of the Central Propaganda Department on the anti-addiction policy
AntiAddictionSystemSDK.showTimeTipsDialog(Activity);
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);