Android Wrapper Documentation
The Backtestx Charts Android wrapper enables developers to integrate high-performance charting interfaces into Android-based Kotlin or Java projects. It handles WebView settings and exposes clean, native layouts.
Overview
Instead of manually configuring WebViews and resource paths, you can import our Android library dependency. The library wraps Android's native WebView container and compiles the asset folder cleanly into your APK.
Installation
1. Add JitPack Repository
Add JitPack to your project-level repository configurations (typically in settings.gradle):
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
2. Add Gradle Dependency
Add the dependency coordinates to your app-level build.gradle file:
implementation 'com.github.backtestx-official:BacktestxChartsAndroid:1.0.0'
}
Usage
1. Declare View in XML Layout
Place the custom chart view inside your layout resource XML file:
android:id="@+id/backtestxChartView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
2. Bind Data (Kotlin)
Reference the view inside your Activity/Fragment and feed standard OHLC data formatted in a JSON string:
val data = \"\"\"
[
{"time": "2026-06-10", "open": 100.0, "high": 105.0, "low": 98.0, "close": 102.5},
{"time": "2026-06-11", "open": 102.5, "high": 108.0, "low": 101.0, "close": 107.2}
]
\"\"\".trimIndent()
chartView.updateData(data)
3. Switch Asset Symbol
Advanced API Controls
If you need to evaluate custom JS functions on your engine directly, you can fetch the raw WebView container:
rawWebView.post {
rawWebView.evaluateJavascript("javascript:window.chart.addIndicator('rsi', { period: 14 });", null)
}