Document Two-Wheelers SDK for Android Guides Developer Guide

Developer Guide

Get a License

Contact your sales representative to obtain a license.

License Authentication for Screen Projection

License Callback Interface

public interface LicenseListener {
    /**
     * Callback for license authentication result.
     *
     * @param errorCode
     *     0: Invalid license (not registered)
     *     1: Valid license
     *     2: Invalid license (expired)
     *     3: Invalid parameters, service not requested
     *     Other: Server-side error code
     * @param errorMessage Error message
     */
    void onLicenseAuthResult(int errorCode, String errorMessage);
}

LicenseManager Methods

public class LicenseManager {

    /**
     * Returns the singleton instance of the LicenseManager.
     *
     * @param context The application context
     * @return The singleton LicenseManager instance
     */
    public static synchronized LicenseManager getInstance(Context context)

    /**
     * Sets the device authentication information. Devices that fail
     * authentication will have limited functionality. Unbound
     * terminal-device pairs are automatically bound.
     *
     * @param licenseId     The license ID
     * @param deviceId      The unique device (head unit) ID
     * @param terminalId    The unique terminal (phone) ID
     * @param listener      Callback for the authentication result
     */
    public void setupLicense(String licenseId, String deviceId, String terminalId, LicenseListener listener)
}

Usage

1. Call LicenseManager.getInstance() to obtain the singleton instance.

2. Call LicenseManager.setupLicense() to request authentication. Paid features are only available after successful authentication.

For navigation SDK usage, please refer to the official website.

License Authentication for Pre-Installed Solutions

License Callback Interface

public interface LicenseListener {
    /**
     * Callback for license authentication result.
     *
     * @param errorCode
     *     0: Invalid license (not registered)
     *     1: Valid license
     *     2: Invalid license (expired)
     *     3: Invalid parameters, service not requested
     *     Other: Server-side error code
     * @param errorMessage Error message
     */
    void onLicenseAuthResult(int errorCode, String errorMessage);
}

LicenseManager Methods

public class LicenseManager {

    /**
     * Returns the singleton instance of the LicenseManager.
     *
     * @param context The application context
     * @return The singleton LicenseManager instance
     */
    public static synchronized LicenseManager getInstance(Context context)

    /**
     * Sets the device authentication information. Devices that fail
     * authentication will have limited functionality. Unbound
     * terminal-device pairs are automatically bound.
     *
     * @param licenseId     The license ID
     * @param deviceId      The unique device (head unit) ID
     * @param listener      Callback for the authentication result
     */
    public void setupLicense(String licenseId, String deviceId, LicenseListener listener)
}

Usage

1. Call LicenseManager.getInstance() to obtain the singleton instance.

2. Call LicenseManager.setupLicense() to request authentication. Paid features are only available after successful authentication.

For navigation SDK usage, please refer to the official website.

Screen Projection: Off-Screen Rendering

Call AMapNaviView.setMapPausedDraw(true) to ensure consistent rendering between foreground and background states.

/**
 * Sets whether to continue rendering the map when the app is in the background.
 *
 * @param isPauseDraw Whether to pause rendering
 */
public void setMapPausedDraw(boolean isPauseDraw)

Simple Network Road Network Rendering

Enable road network mode to render only the background and road network on the AMapNaviView, hiding POIs, buildings, navigation controls, and other UI elements. When road network mode is enabled, all navigation-related components are hidden internally, displaying only the road network.

AMapNaviView mAMapNaviView = findViewById(R.id.navi_view);

// Must be set first
mAMapNaviView.setMapPausedDraw(true);

// Enable road network mode
mAMapNaviView.setRoadMode(true);

Capture a Map Screenshot

/**
 * Asynchronously captures a screenshot of the current map view.
 * The callback is triggered only when the map is in the foreground
 * and has been successfully initialized.
 *
 * @param screenShotListener Callback for the screenshot result
 */
mAMapNaviView.setOnMapScreenShotListener(new AMap.OnMapScreenShotListener() {
    @Override
    public void onMapScreenShot(Bitmap bitmap) {
        // Handle the bitmap as needed
    }

    @Override
    public void onMapScreenShot(Bitmap bitmap, int i) {
        // Handle the bitmap as needed
    }
});

Note: The SDK does not recycle the Bitmap objects returned in the callbacks. You must recycle them after use to prevent memory growth.

Set the Background Color

mAMapNaviView.setMapBackgroundColor(color);