目录

HiAnalytics

Class Info

com.huawei.hms.analytics.HiAnalytics

Provides methods to obtain Analytics Kit instances.

Public Method Summary

Qualifier and Type

Method Name and Description

static HiAnalyticsInstance

getInstance(Activity activity)

Obtains an Analytics Kit instance.

static HiAnalyticsInstance

getInstance(Context context)

Obtains an Analytics Kit instance.

static HiAnalyticsInstance

getInstance(Context context, String routePolicy)

Obtains an Analytics Kit instance. To call this method, you must set a data processing location.

Public Methods

[h2]getInstance(Activity activity)

Method

public static HiAnalyticsInstance getInstance(Activity activity)

Obtains an Analytics Kit instance. Analytics Kit will be initialized in the main thread based on your configuration.

NOTE:

Parameters

Name

Description

activity

Activity instance.

Returns

Type

Description

HiAnalyticsInstance

Analytics Kit instance.

[h2]getInstance(Context context)

Method

public static HiAnalyticsInstance getInstance(Context context)

Obtains an Analytics Kit instance. Analytics Kit will be initialized in the main thread based on your configuration.

If the initialization is performed in Context mode, automatic collection of the LAUNCHAPP event is affected, and in some scenarios, the app launch mode cannot be obtained.

NOTE:

Parameters

Name

Description

context

Context instance.

Returns

Type

Description

HiAnalyticsInstance

Analytics Kit instance.

[h2]getInstance(Context context, String routePolicy)

Method

public static HiAnalyticsInstance getInstance(Context context, String routePolicy)

Obtains an Analytics Kit instance. Analytics Kit will be initialized in the main thread based on your configuration.

If the initialization is performed in Context mode, automatic collection of the LAUNCHAPP event is affected, and in some scenarios, the app launch mode cannot be obtained. In this case, an Activity instance needs to be passed for initializing Analytics Kit.

NOTE:
  • Initialize the Analytics SDK in onCreate of the first Activity or Application. Otherwise, the collection of lifecycle-related events will be affected.
  • To call the method for setting multiple data processing locations, download the latest app configuration file from AppGallery Connect. To download the file, go to Project settings and download agconnect-services.json from the App information area.

Parameters

Name

Description

context

Context instance.

routePolicy

Data processing location.

The options are CN (China), DE (Germany), SG (Singapore), and RU (Russia).

NOTE:

The data processing location you set must have the data storage permission. Otherwise, data cannot be reported to it.

Returns

Type

Description

HiAnalyticsInstance

Analytics Kit instance.