Set the Username with the Aternity Android SDK (setUsername)

You can set a username for a mobile app in Aternity Mobile SDK to be consistent with desktops and laptops, so you can track this user's experience across all devices and platforms.In Android, you can set the username of the application at initialization, or separately using the setUsername method from the Aternity class.

Example of usernames for mobile devices displayed in the dashboards

The Aternity class provides the getInstance method which returns a singleton object. You should call the class's methods using the singleton object, to avoid manually creating and maintaining the Aternity object.

Before You Begin

Before embedding Aternity's monitoring into an Android mobile app, verify your Mac conforms to the following minimum system requirements (Aternity Android Wrapper or Aternity Android Mobile SDK):

Attribute Requirement (Android Wrapper and Aternity Android SDK)

Operating system

Mac OS X 10.7 or later.

Java Developer Kit

JDK 1.8 or later.

Programming environment

Google Android Studio or a standalone Android SDK.

Using the SDK Manager, install the latest Android SDK tools (platform tools and build tools) for SDK Platform API level 16 or newer.

Connectivity

Internet access.

App resource usage

When you add Aternity functionality to an Android app:

  • Disk storage barely changes at all.

  • RAM size is an extra 5-10MB.

  • CPU usage rises by 1%.

In addition, ensure you have already done the following:

Declaration

void setUsername(String name); 

Parameters

Parameter Description

name

Set this to be the username you want to appear in the dashboards, defined as a string.

Example

import com.aternity.sdk.Aternity;
public class CardViewActivity extends Activity {
    public void processLogin() {
        //report username to Aternity
        Aternity.getInstance().setUsername("brandi_calton");
    }
}