All Products
Search
Document Center

Mobile Platform as a Service:Android client development

Last Updated:Jan 14, 2026

This topic describes how to develop custom event analysis function on the Android client, including:

  1. Integrate MAS component

  2. Record event logs

  3. Report logs

Integrate MAS component

Integrate MAS component by referring to Access Android - Quick start guide.

Record event logs

The section guides you how to record event logs through a code sample, and gives introduces the parameters involved in the code sample.

Code sample

In the following code example, the client will record the business ID, event ID, payment time, user ID, and payment method corresponding to the event.

import com.mpaas.mas.adapter.api.MPLogger;

import java.util.HashMap;
import java.util.Map;

// Specify the business ID
String bizType = "Pay";
// Event ID
String logId = "PayResults";
// Add attributes
Map<String, String> params = new HashMap<>(4);
// Attribute: payment time. Key corresponds to the attribute ID and Value corresponds to the attribute value.
params.put("pay_time", String.valueOf(System.currentTimeMillis()));
// Attribute: user ID
params.put("user_id", "the-userId");
// Attribute: payment mode
params.put("payment_method", "alipay");
// Print logs
MPLogger.event(logId, bizType, params);

Parameters description

Parameter

Description

bizType

  • bizType specifies the business ID (also known as business code or business type), which is the unique identifier of a business. In the code sample, bizType is set to Pay, indicating payment business.

  • bizType affects the log file name on the client. The log file naming format is timestamp_package name-process_bizType.

logId

logId specifies the event ID, which is the unique identifier of an event. For more information, see the description of tutorial scenario in About this tutorial.

params

params stores attributes associated with events. In params.put("param-key", "param-value"):

  • param-key: corresponding to the attribute ID. For more information, see the description of tutorial scenario in About this tutorial.

  • Param-value: corresponding to the attribute value. The attribute value is stored as a character string on the client. In actual analysis, the server supports converting the attribute value into a character, integer, or float value.

Report logs

By default, when logs cached on the client reach a certain number or the program runs in the backend for a certain period of time, local logs are automatically reported to the MAS server. During development testing, you can call the following APIs to forcibly report local logs to the server immediately:

import com.mpaas.mas.adapter.api.MPLogger;
MPLogger.uploadAll();