Mobile Development 9 min read

Baidu Mobile SDKs Overview: Statistics, Map, and Voice Integration Guide

This article provides a comprehensive guide to Baidu's mobile SDKs—including Statistics, Map (location), and Voice—detailing their features, platform-specific integration steps for Android and iOS, and sample code snippets for developers to implement analytics, precise positioning, and speech recognition in their apps.

Baidu Intelligent Testing
Baidu Intelligent Testing
Baidu Intelligent Testing
Baidu Mobile SDKs Overview: Statistics, Map, and Voice Integration Guide

Background Introduction

Baidu offers a suite of APIs for Android and iOS devices, covering statistics, location, voice, and more, enabling developers to embed analytics, geolocation, and semantic speech recognition into their applications.

Baidu Statistics SDK – Keep the Numbers in Hand

Baidu Mobile Statistics (http://mtj.baidu.com) is a free, industry‑leading analytics tool for iOS and Android. By integrating the Statistics SDK, developers can monitor app performance, gain real‑time insights, and analyze user behavior through comprehensive reporting.

Usage

The SDK supports basic statistics, error tracking, and custom event reporting.

Android

(1) Insert the following calls in each Activity’s onResume() and onPause() methods:

StatService.onResume(Context context);

StatService.onPause(Context context);

(2) Alternatively, extend the provided StartService class via StatActivity , which internally calls the above methods.

iOS

Implement the two methods:

void pageviewStartWithName:(NSString*)name;

void pageviewEndWithName:(NSString*)name;

Call pageviewStartWithName when a view appears and pageviewEndWithName when it disappears, using the same name identifier.

Error Statistics (Android)

In the Activity’s onCreate() , insert:

void setOn(Context context, int flag);

The flag toggles error analysis functionality.

Custom Event Statistics (Android)

Define event IDs in the Baidu Statistics console, then call:

void onEvent(Context context, String event_id, String label);

void onEvent(Context context, String event_id, String label, int acc);

iOS custom event call:

(void)logEvent:(NSString*)eventId eventLabel:(NSString*)eventLabel

Baidu Map SDK – Intelligent, Precise, Efficient Location

The Baidu Map Android Location SDK provides simple LBS interfaces for high‑accuracy positioning.

1. Initialization Settings

(1) Add to AndroidManifest.xml :

<service Android:name="com.baidu.location.f" Android:enabled="true" Android:process=":remote"></service>

(2) Declare required permissions (network, GPS, Wi‑Fi, etc.).

(3) Set the API key:

<meta-data Android:name="com.baidu.lbsapi.API_KEY" Android:value="key" /> // key obtained from Baidu

(4) SDK classes overview:

com.baidu.location.BDLocation;

com.baidu.location.BDLocationListener;

com.baidu.location.LocationClient;

com.baidu.location.LocationClientOption;

com.baidu.location.BDNotifyListener; // for location alerts

com.baidu.location.Poi;

2. Location Interface

(1) Initialize LocationClient in the main thread:

public LocationClient mLocationClient = null;

public BDLocationListener myListener = new MyLocationListener();

public void onCreate() {

mLocationClient = new LocationClient(getApplicationContext()); // instantiate

mLocationClient.registerLocationListener(myListener); // register listener

}

(2) Configure parameters with LocationClientOption (mode, coordinate type, GPS, address, POI, etc.).

(3) Implement BDLocationListener :

public class MyLocationListener implements BDLocationListener {

@Override

public void onReceiveLocation(BDLocation location) {

// handle location result

}

}

(4) Start location updates:

mLocationClient.start();

Baidu Voice SDK – Hands‑Free Speech Recognition

Baidu Voice provides both UI‑based dialog control and low‑level API integration for speech recognition on mobile devices.

1. Voice Recognition Control (Dialog)

Android

Create a dialog instance and set a listener:

BaiduASRDigitalDialog mDialog = new BaiduASRDigitalDialog(this, params);

mDialog.setDialogRecognitionListener(new DialogRecognitionListener() {

public void onResults(Bundle arg0) {

ArrayList rs = results != null ? results.getStringArrayList(RESULTS_RECOGNITION) : null;

if (rs != null && rs.size() > 0) {

recognition_result = rs.get(0);

}

}

});

Start the dialog with mDialog.show();

iOS

[recognizerViewController startWithParams:paramsObject];

2. API‑Based Recognition

Android

Instantiate the recognizer and set a listener:

private Android.speech.SpeechRecognizer mSpeechRecognizer;

mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName(this, VoiceRecognitionService.class));

RecognitionListener listener = new RecognitionListener() { /* implement callbacks */ };

mSpeechRecognizer.setRecognitionListener(listener);

Start listening:

Intent recognizerIntent = new Intent();

// configure intent extras as needed

mSpeechRecognizer.startListening(recognizerIntent);

Stop listening with mSpeechRecognizer.stopListening();

iOS

Obtain the shared instance and start recognition:

BDVoiceRecognitionClient *sharedInstance = [BDVoiceRecognitionClient sharedInstance];

int startStatus = [sharedInstance startVoiceRecognition:self];

Handle the start status (e.g., EVoiceRecognitionStartWorking indicates success).

Conclusion

If you find this content useful, feel free to share it with friends and colleagues.

Note: This article is Baidu exclusive content; please credit “Baidu QA” when reproducing.

iOSAndroidstatisticsVoice RecognitionlocationMobile SDKBaidu
Baidu Intelligent Testing
Written by

Baidu Intelligent Testing

Welcome to follow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.