Android Framework API References
Initialization Method
GlamAr.init(
context: Context,
accessKey: String,
overrides: GlamAROverrides? = null,
webView: WebView? = null,
debug: Boolean = false
)
Parameter Descriptions
| Parameter | Type | Required | Description |
|---|---|---|---|
| context | Context | Yes | The Android context, typically passed from an Activity or Fragment. Used for WebView creation and permission handling. |
| accessKey | String | Yes | Your unique Access key to authenticate the SDK usage. |
| overrides | GlamAROverrides? | No | Optional configuration object to control AR behavior, UI, and metadata. See GlamAROverrides for details. |
| webView | WebView? | No | If provided, the SDK will use this WebView instance instead of creating a new one. Allows full control over rendering. Defaults to null. |
| debug | Boolean | No | Enables detailed logging from the SDK. Useful for development/debugging. Defaults to false. |
GlamAROverrides allows developers to customize the behavior, appearance, and initialization of the GlamAR SDK when integrating it into an Android app.
You can pass this configuration object directly into the SDK initialization:
GlamAr.initialize(
context = this,
accessKey = "your-access-key",
overrides = GlamAROverrides(...) // ← Custom behavior here
)
GlamAROverrides Structure
category: String?
Defines the initial AR category (e.g. sunglasses, necklace,earrings). Optional.
meta: Map<String, Any?>?
Contains initialization metadata. Use preloadMLModels to download ML models during SDK initialization. AR Try-On supports face, hair, hand, and light.
Full Example
val overrides = GlamAROverrides(
category = "sunglasses",
meta = mapOf(
"preloadMLModels" to listOf("face", "hair", "hand", "light")
)
)
Post-Initialization Methods
applyBySku
GlamAr.applyBySku(skuId);
Load a virtual try-on using applyBySku method and passing the relevant SKU Id.
Return Value: None
| Parameters | Type | Description |
|---|---|---|
| SKU Id | string | A SKU ID. |
applyByCategory
GlamAr.applyByCategory(category)
Pass a category (e.g.,
makeup,eyewear,jewellery), which the SDK will use to fetch all corresponding SKUs from the Console’s product inventory.
Return Value: None
GlamAr.applyByCategory("makeup")
If storefront-specific filtering is required, pass storeFront as an optional second argument.
import io.pixelbin.glamar.model.ApplyCatalogOptions
GlamAr.applyByCategory(
"makeup",
ApplyCatalogOptions(storeFront = "store_a")
)
| Parameters | Type | Description | Options |
|---|---|---|---|
| category | string | Pass any compatible category |
|
| options (optional) | ApplyCatalogOptions? | Optional catalog filter object. Currently supports storeFront. | ApplyCatalogOptions(storeFront = "store_a") |
applyBySubCategory
GlamAr.applyBySubCategory(subCategory)
Pass a subcategory (e.g.,
lipstick,sunglasses,necklace), which the SDK will use to fetch all corresponding SKUs from the Console’s product inventory.
Return Value: None
GlamAr.applyBySubCategory("lipstick")
If storefront-specific filtering is required, pass storeFront as an optional second argument.
import io.pixelbin.glamar.model.ApplyCatalogOptions
GlamAr.applyBySubCategory(
"lipstick",
ApplyCatalogOptions(storeFront = "store_a")
)
| Parameters | Type | Description | Options |
|---|---|---|---|
| subCategory | string | Pass any compatible subcategory |
|
| options (optional) | ApplyCatalogOptions? | Optional catalog filter object. Currently supports storeFront. | ApplyCatalogOptions(storeFront = "store_a") |
applyMultipleConfigData
GlamAr.applyMultipleConfigData(skuConfigArray);
Display multiple SKU types at once. The input should be an array of sku configs. Each item can be of diffrent subcategory eg:
sunglasses,caps,earrings, etc.
Return Value: None
| Parameters | Type | Description |
|---|---|---|
| skuConfigArray | object | An Array of SKU Configs |
Following is an example of above skuConfigArray for applyMultipleConfigData.
data class EffectAsset3D(
val id: String,
val url: String
)
data class EnvSettings(
val useDefaultEnvironment: Boolean
)
data class ArEffect(
val envSettings: EnvSettings,
val effectAssets3D: List<EffectAsset3D>
)
data class SkuConfig(
val category: String,
val subCategory: String,
val status: String,
val productName: String? = null,
val productImage: String? = null,
val arEffect: ArEffect,
val meta: Map<String, Any?>? = null
)
val data = listOf(
SkuConfig(
category = "eyewear",
subCategory = "eyeglasses",
status = "PUBLISHED",
arEffect = ArEffect(
envSettings = EnvSettings(useDefaultEnvironment = true),
effectAssets3D = listOf(
EffectAsset3D(id = "full", url = "VALID-ASSET-URL") // Valid Asset url
)
)
),
SkuConfig(
category = "accessories",
subCategory = "caps",
status = "PUBLISHED",
productName = "Test cap",
productImage = "VALID-ASSET-IMAGE-URL", // Valid image url
arEffect = ArEffect(
envSettings = EnvSettings(useDefaultEnvironment = true),
effectAssets3D = listOf(
EffectAsset3D(id = "full", url = "VALID-ASSET-URL") // Valid Asset url
)
)
),
)
GlamAr.applyMultipleConfigData(data);
Users will see separate tabs for each category type in the SDK UI.
addEventListener
GlamAr.addEventListener(eventName, handlerFunction);
Adds the listener to the given event name.
Return Value: None
| Parameters | Type | Description |
|---|---|---|
| eventName | string | A Name of specific event or "*" To listen to the all the events. |
| handlerFunction | function | Your handler function that will listen to callback. |
removeEventListener
GlamAr.removeEventListener(eventName, handlerFunction);
Removes the given listener for the event name.
Return Value: None
| Parameters | Type | Description |
|---|---|---|
| eventName | string | A Name of specific event or "*" To remove all the events. |
| handlerFunction | function | Your handler function that will listen to callback. |
isLoaded
GlamAr.isLoaded();
Returns the status of module loading.
Return Value:trueif loaded, otherwisefalse
| Parameters | Description |
|---|---|
None | No parameters required. |
reset
Removes all applied effects when called without arguments. In multi-try-on, pass a subcategory string or an options object/map to remove selected effects while keeping the others.
GlamAr.reset()
GlamAr.reset("blush")
GlamAr.reset(mapOf("subCategory" to "blush"))
GlamAr.reset(mapOf("skuIds" to listOf("sku-1", "sku-2")))
| Parameter | Type | Description |
|---|---|---|
value | String or Map<String, Any> | Optional. A subcategory string is shorthand for the subCategory option. |
subCategory | String | Subcategory to clear, such as blush. |
skuIds | List<String> | IDs of applied SKUs to remove. Pass individual IDs as list entries. |
If both filters are supplied, a nonempty skuIds list takes precedence over subCategory. Omitting the argument, passing an empty string, or passing options with no nonempty filter clears all effects.
Returns no value.
configChange
Updates an adjustment for the active try-on. Availability depends on the current product and experience. skuId and subCategory select the makeup opacity target during multi-try-on; they do not scope finger, position, or scale adjustments.
Use configChange(type, value, skuId, subCategory). Only type is required; Kotlin named arguments let you omit unused optional parameters.
GlamAr.configChange("opacity", 0.5)
GlamAr.configChange("fingers", 2)
GlamAr.configChange("horizontal", 0)
GlamAr.configChange("vertical", 0)
// Target makeup opacity during multi-try-on.
GlamAr.configChange("opacity", 0.5, skuId = "sku-1")
GlamAr.configChange("opacity", 0.5, subCategory = "lipstick")
// Select the makeup opacity target without changing its value.
GlamAr.configChange("opacity", subCategory = "lipstick")
| Parameter | Type | Description |
|---|---|---|
type | String | Required. opacity (also accepted as intensity), fingers, horizontal, vertical, or scale. |
value | Number? | Numeric adjustment. Supply a value when changing an adjustment. For opacity/intensity, omitting the value selects the target without changing its opacity. |
skuId | String | Optional applied makeup SKU ID to target. |
subCategory | String | Optional applied makeup subcategory to target, such as lipstick or blush. |
Pass one target selector per call. With neither selector, the SDK uses its active makeup target. Returns no value.
setViewportMirrored
GlamAr.setViewportMirrored(state);
Enables or disables mirrored viewport rendering for AR Try-On.
Return Value: None
GlamAr.setViewportMirrored(true); // Enable mirrored viewport
GlamAr.setViewportMirrored(false); // Disable mirrored viewport
| Parameters | Type | Description | Options |
|---|---|---|---|
| state | Boolean | Controls whether the AR viewport should render in mirrored mode. |
|
close
GlamAr.close();
Closes canvas and returns to the main widget page.
Return Value: None
| Parameters | Description |
|---|---|
None | No parameters required. |
snapshot
GlamAr.snapshot();
Takes a snapshot of the current result window. Result of the screen can be get from photo-loaded event in
base64formate.
Return Value: none
| Parameters | Description |
|---|---|
None | No parameters required. |
comparison
GlamAr.comparison(state, skus);
Toggles comparison mode in AR widget.
Return Value: None
Pass a state (i.e, open or close) to toggle between UI and with it 2 SKU ids or Skuconfig of same subcategory say sunglasses or necklace. Diffrent subcategory comparision is not supoorted. The first sku will be shown on the left side and the other one on the right side.
| Parameters | Type | Description | Options |
|---|---|---|---|
| state | string | State to show or hide the UI respectively | open close |
| skus | string[] | object[] | Provide 2 SKU Ids or 2 SKU json in an array | ["skudID1", "skudID2"] |
GlamAr.comparison("open", ["skudID1", "skudID2"]); // replace skudID1 and skudID2 with two SKU id's
GlamAr.comparison("close"); // When we send close we don't need to send SKUs
setExperience
GlamAr.setExperience(experience, options)
Switches the active SDK experience without reloading the full SDK. Use this to move between AR Try-On and Skin Analysis faster after the GlamAR module is already loaded.
Return Value: None
import io.pixelbin.glamar.model.VtoExperienceOptions
import io.pixelbin.glamar.model.SkinAnalysisExperienceOptions
GlamAr.setExperience("vto", VtoExperienceOptions(category = "eyewear"))
GlamAr.setExperience("vto", VtoExperienceOptions(subCategory = "lipstick"))
GlamAr.setExperience("vto", VtoExperienceOptions(skuId = "Your sku id"))
GlamAr.setExperience(
"skinAnalysis",
SkinAnalysisExperienceOptions(appId = "0732f85d-5768-462e-a50a-174840438a69")
)
| Parameters | Type | Required | Description |
|---|---|---|---|
| experience | String | Yes | Experience to switch to. Valid values are vto and skinAnalysis. |
| options |
| Yes | Experience-specific options used to start the selected flow. |
| category | String? | Required for VTO if subCategory or skuId is not provided | Category to load when switching to AR Try-On. |
| subCategory | String? | Required for VTO if category or skuId is not provided | Subcategory to load when switching to AR Try-On. |
| skuId | String? | Required for VTO if category or subCategory is not provided | The exact merchant SKU from variants[].skuId, not a product ID or variant UUID. |
| appId | String | Required for Skin Analysis | Skin Analysis app ID to load when switching to Skin Analysis. |
For AR Try-On, pass only one selector in a single call: category, subCategory, or skuId. Do not pass multiple selectors together, such as category with subCategory, because only one value will be used.
Selector values are trimmed. If multiple selectors are supplied, the SDK uses the first nonblank value in this priority order: category, then subCategory, then skuId. For example, if both category and subCategory are passed, a nonblank category will be preferred.
Listen to experience-changing, experience-changed, and experience-change-failed events to track switch progress and handle failures.
open
Use open and its mode variants only when you disable or override the SDK's built-in hero screen and implement your own screen or launch buttons. The built-in hero screen already provides buttons to open the SDK, so no open call is needed when using it. After applying a SKU, call the appropriate variant from your custom button handler.
GlamAr.open();
Opens the AR widget.
Return Value: None
| Parameters | Type | Description | Options |
|---|---|---|---|
| mode | string | Opens Live-Tryon, Model/Image-tryon and Model Viewer | modelViewer imgTryOn |
| imgURL | string | Valid image URL | Any valid URL |
-
No parameters: Start Live VTO
GlamAr.open(); -
Model Viewer: Start Model Viewer
GlamAr.open("modelViewer"); -
Image Try-On:
- Opens the image/model selection screen:
GlamAr.open("imgTryOn"); - Opens try-on directly with a specific image:
GlamAr.open("imgTryOn", "url_of_image");
- Opens the image/model selection screen:
Switching Views
-
While in Live or Image mode, calling:
GlamAr.open("modelViewer");will open the model viewer. Calling
GlamAr.open()again returns to the selected Try-On type. -
To switch from Live to Image mode, call:
GlamAr.back();This resets the Try-On session and then call
GlamAr.open()with desired parameter
Note: The SKU must already be applied. If not, the SDK will display an error.
Eye PD Measurement Flow
We provide an integrated supports for eye pupillary distance (PD) scanning. This is activated when viewing any eyeware categories. If user wants to show his own UI and use this service we have function GlamAR.eyePD() for that case.
GlamAr.eyePD("start"); // To launch or restart Eye PD flow
GlamAr.eyePD("close"); // To exit Eye PD and return to active Try-On
Events
The sku-applied event includes the applied SKU configuration in data. See the platform-specific callback examples there to read the correct payload shape.
The GlamAR SDK emits various events throughout its lifecycle to help you monitor state, respond to user actions, and handle success or failure cases.
You can register for these events using the SDK's event listener system:
glamArView.addEventListener("loaded") {
// SDK has fully loaded
}
glamArView.addEventListener("photo-loaded") { data ->
// Handle screenshot data
}
Each event is triggered from within the GlamAR SDK and may optionally include a payload. Check Events Page for event details.