Creating your first SciChart Android App
Playing around with SciChart Android Examples Suite is great, but you are probably interested in creating your own application by adding some charts! Let's get started and create our first SciChart Android App using Kotlin.
Setting up a new Android Application
Assuming you've created an Android project in either Java
, Kotlin
or even Xamarin.Android
- next step should be integrating SciChart.framework. The easiest way of doing so is by using Maven.
- Open the "build.gradle" file for the project and declare a new Maven repository in the "repositories" node. Use the URL from above:
repositories {
google()
mavenCentral()
// Declare a Maven repository for SciChart
maven { url 'https://www.myget.org/F/abtsoftware-bleeding-edge/maven' }
maven { url 'https://www.myget.org/F/abtsoftware/maven' }
}
- Open the "build.gradle" file for a module which SciChart is intended to be used within. Add SciChart Android libraries as module dependencies:
def sciChart_version = "4.5.0.4851"
// Declare SciChart libraries as module dependencies
implementation (group: 'com.scichart.library', name: 'core', version: sciChart_version, ext: 'aar')
implementation (group: 'com.scichart.library', name: 'data', version: sciChart_version, ext: 'aar')
implementation (group: 'com.scichart.library', name: 'drawing', version: sciChart_version, ext: 'aar')
implementation (group: 'com.scichart.library', name: 'charting', version: sciChart_version, ext: 'aar')
implementation (group: 'com.scichart.library', name: 'charting3d', version: sciChart_version, ext: 'aar')
// Declare SciChart extension library as module dependencies
implementation (group: 'com.scichart.library', name: 'extensions', version: sciChart_version, ext: 'aar')
implementation (group: 'com.scichart.library', name: 'extensions3d', version: sciChart_version, ext: 'aar')
Note
You can also get the extensive sample app downloading the SciChart Android Trial package, which can be used for manual integration of SciChart.framework.
Set the License Key
Before you build and run the application, you will need to apply a trial or purchased license key. You can find full instructions on the page Licensing SciChart Android.
You can fetch a Trial License Key directly from the Downloads page following instructions from Licensing SciChart Android. Or, if you have purchased SciChart Android, you can find the full purchased license keys at your SciChart Account Page.
When you have your key, you should apply it via setRuntimeLicenseKey(String key) like below:
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
// Set your license code here to license the SciChart app
// You can get a trial license key from https://www.scichart.com/licensing-scichart-android/
// Purchased license keys can be viewed at https://www.scichart.com/profile
//
SciChartSurface.setRuntimeLicenseKey("");
}
}
After creating MyApp add this to AnroidManifest file in application tag:
...
<application
android:name=".MyApp"
...
Note
The License Key must be set in your app once, and once only before any SciChartSurface instance is initialized.
From here, you can create 2D or 3D chart. Please refer to the following sections for more information:
The SciChartSurface Type
The root 2D chart view is called the SciChartSurface. This is the Android View you will be adding to your applications wherever you need a chart. You can add more than one SciChartSurface, you can configure them independently, and you can link them together.
Since this is a Quick Start Example, we will use the one instance of SciChartSurface, so let’s start by declaring one!
Declaring a SciChartSurface Instance
There few ways of adding SciChartSurface to your application. We will look more closely into the following: