개발자 가이드
User GuideDeveloper GuideAPI Guide🏠
English
English
  • 홈
  • 공통
    • Unified ID Linkage Scenario
    • Constant
    • FAQ
  • 플랫폼 별 가이드
    • Android
      • Link up
      • Event
      • Set User Identification Information
      • User Profile Settings
      • Action
        • Push
        • In-app messages
        • Notification Talk
        • Message
      • Privacy Policy
        • Support for Privacy Protection
        • Preparing for data disclosure requirements on Google Play
      • Release Notes
    • iOS
      • Link up
      • Event
      • Set user identification information
      • User Profile Settings
      • Action
        • Push
        • In-app messages
        • Notification Talk
        • message
      • Release Notes
    • HybridApp
      • Link up
    • Web
      • Link up
      • Event
      • Set user identification information
      • User Profile Settings
      • Action
        • In-app messages
        • Notification Talk
        • Message
      • Advanced use cases
        • Additional Settings
      • Release Notes
Powered by GitBook
On this page
  • Before you start
  • Service Settings
  • Support Information
  • Installing the SDK
  • Adding dependencies
  • SDK Initialization
  • Initialize
  • Set up your Google Advertising ID (optional)
  • SDK Setup
  • Activate log
  • Change the log level
  • Complete
  1. 플랫폼 별 가이드
  2. Android

Link up

PreviousAndroidNextEvent

Last updated 3 months ago

This document covers how to integrate the DFINERY Android SDK into Android. Installing the DFINERY SDK provides event analytics, user profiles, and actions.

Before you start

Service Settings

You must check Android in the Data Source section on the Service Management/Service Information page of

Support Information

  • Minimum supported SDK: Android 4.4+ / API 19+

  • Target SDK: 33

  • Recently compiled Firebase Cloud Messaging version: 24.0.0

Installing the SDK

Adding dependencies

To apply the DFINERY SDK dependency in your app, complete the following steps:

1. Add mavenCentralin repositories to fetch maven dependencies.

allprojects {
    repositories {
        mavenCentral()
    }
}
pluginManagement {
    repositories {
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
}

2. Open the build.gradle file inside the app's module directory.

 dependencies {
  implementation 'com.google.android.gms:play-services-appset:16.0.2'
  //Get the latest version from https://mvnrepository.com/artifact/com.igaworks.dfinery/android-sdk
  implementation 'com.igaworks.dfinery:android-sdk:HERE_LATEST_VERSION'
}
 dependencies {
  implementation("com.google.android.gms:play-services-appset:16.0.2")
  //Get the latest version from https://mvnrepository.com/artifact/com.igaworks.dfinery/android-sdk
  implementation("com.igaworks.dfinery:android-sdk:HERE_LATEST_VERSION")
}

SDK Initialization

Initialize

To initialize the DFINERY SDK in your app, complete the following steps:

1. Create an object that inherits Application. If an inherited object already exists, use that object.

public class BaseApplication extends Application
class BaseApplication: Application()
@Override
public void onCreate() {
    super.onCreate();
}
override fun onCreate() {
    super.onCreate()
}

3. Write the following code in the onCreate() method.

Dfinery.getInstance().init(this, "SERVICE_KEY");
Dfinery.getInstance().init(this, "SERVICE_KEY")

The following code snippet shows an example of when initialization is complete.

public class BaseApplication extends Application{
    @Override
    public void onCreate() {
        super.onCreate();
        Dfinery.getInstance().init(this, "SERVICE_KEY");
    }
}
class BaseApplication: Application(){
    override fun onCreate() {
        super.onCreate()
        Dfinery.getInstance().init(this, "SERVICE_KEY")
    }
}

4. Register the application written in AndroidManifest.xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application
        android:name=".BaseApplication">
    </application>
</manifest>

5. Add the required permissions to AndroidManifest.xml.

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

Set up your Google Advertising ID (optional)

To collect the Google Advertising ID, setGoogleAdvertisingId()you must set it manually via the method.

1. Open the build.gradle file inside your app's module directory.

 dependencies {
  implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
}
 dependencies {
  implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
}

3. Add the required permissions to AndroidManifest.xml.

<uses-permission android:name="com.google.android.gms.permission.AD_ID" />

4. Set the advertising ID via thesetGoogleAdvertisingId() method.

The advertising ID collection logic should be run in a separate thread. The code snippet below creates a Thread and runs it, but you can use other methods (AsyncTask, coroutine, etc.) depending on your needs.

new Thread(new Runnable() {
    @Override
    public void run() {
        try {
            AdvertisingIdClient.Info idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
            DfineryProperties.setGoogleAdvertisingId(idInfo.getId(), idInfo.isLimitAdTrackingEnabled());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}).start();
Thread {
    try {
        val idInfo = AdvertisingIdClient.getAdvertisingIdInfo(
            applicationContext
        )
        DfineryProperties.setGoogleAdvertisingId(idInfo.id, idInfo.isLimitAdTrackingEnabled)
    } catch (e: Exception) {
        e.printStackTrace()
    }
}.start()

SDK Setup

You can set options such as enabling logs when initializing the SDK.

Activate log

Logging can be enabled using DfineryConfig, which applies the settings of DFINERY. DfineryConfig can init()be applied by passing it as a parameter when calling a method, or res/values/dfinery.xmlcan be set using.

setLogEnable(boolean enable)
  • The first argument, enableis a value that sets whether to display the log or not. The default value is false.

You can set the BuildConfig.DEBUG value to output logs only in debug mode and not output them during deployment.

DfineryConfig config = new DfineryConfig.Builder()
    .setLogEnable(true)
    .build();
Dfinery.getInstance().init(this, "SERVICE_KEY", config);
val config = DfineryConfig.Builder()
    .setLogEnable(true)
    .build()
Dfinery.getInstance().init(this, "SERVICE_KEY", config)
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="com_igaworks_dfinery_log_enable" translatable="false">true</bool>
</resources>

Change the log level

Log levels can be set using DfineryConfig, which applies Dfinery's settings. DfineryConfig can be applied as a parameter when calling the init() method, or set using res/values/dfinery.xml.

setLogLevel(int logLevel)
  • The first argument, logLevel, is a value that sets the log display level. The default value is Log.ERROR(6).

DfineryConfig config = new DfineryConfig.Builder()
    .setLogLevel(Log.DEBUG)
    .build();
Dfinery.getInstance().init(this, "SERVICE_KEY", config);
val config = DfineryConfig.Builder()
    .setLogLevel(Log.DEBUG)
    .build()
Dfinery.getInstance().init(this, "SERVICE_KEY", config)
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="com_igaworks_dfinery_log_level">2</integer>
</resources>

Complete

SDK installation and initialization is complete.

3. Add SDK dependencies for and required components to dependencies.

DFINERY requires dependency to collect AppSetId.

2. Override the method in an object that inherits Application

The Service ID can be found in the path of Service Management/Service Information/Key Information/Service Key

2. Add to dependencies.

Log level values ​​follow the definition of constant values ​​in .

the latest version of DFINERY SDK
play-services-appset
onCreate()
the DFINERY Console.
the dependencies required to collect the advertising ID
android.util.Log
the DFINERY console.
Service Information