Android


This section explains the configuration and initialization effort required for SDK integration of Android game. After complete the efforts described in this section, please continue the integration effort for other function module.

Setting Up a Development Environment

1. Download KTplay Android SDK

Download and unzip the KTplay SDK to designated directory. Tips: in Windows, suggest to have the SDK directory on the same disk drive as the game's project.

2. Setup Project configuration

Import downloaded KTplay Android SDK as module into your game project in Android Studio.

  • in Android Studio, import KTplay project. e.g. in menu
    File->New->Import Module, and select KTplaySDK project for the import.

  • In your game project, add module from KTplay SDK. In game project 's build.gradle document, add the following dependence

    dependencies {
        //other dependences
        compile project(':KTPlay')
    }

SDK Runtime Event Handling

1. SDK Initialization

In the onCreate method of game's main Activity, call KTPlay.startWithAppKey method to initialize KTplay SDK.

KTPlay.startWithAppKey(Activity,"AppKey","AppSecret");

2. onPause and onResume handling

To make sure proper operation of KTplay SDK, call KTPlay's onPause and onResume methods accordingly in your Activity's onPause and onResume methods.

If game have more than one Activity, every Activity use KTplay feature need to call KTplay SDK's onPause and onResume method.

@Override
public void onPause(){
    KTPlay.onPause(this);
    super.onPause();
}
@Override
public void onResume(){  
    KTPlay.onResume(this);
    super.onResume();
}

Points to be Aware

1. ProGuard Rules

If you will shrink your APK with ProGuard, please append following content to your ProGuard rules file (proguard-rules.pro).

-keep public class com.ktplay.sdk.R{*;}
-keep public class com.ktplay.sdk.R$**{*;}
-keep public class com.ktplay.open.KryptaniumAdapter
-keep public class com.ktplay.open.KryptaniumAdapter{*;}
-keep public class com.ktplay.open.KryptaniumAdapter$**{*;}
-keep public class com.ktplay.open.*{*;}
-keep public class com.google.android.gms.ads.identifier.AdvertisingIdClient{*;}
-keep public class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{*;}
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.