Quickstart

Get the StreamLayer Element on screen in under 5 minutes with Android

Android Quickstart

This quickstart gets you from zero to seeing the StreamLayer Element on screen in under 5 minutes. For detailed configuration options, see the Integration Guide.

System Requirements

  • Android Studio 4.0+
  • Target SDK 33+
  • Min SDK 21

Add Maven Dependency

In your project's build.gradle:

dependencies {
    implementation 'io.streamlayer:androidsdk:latest'
}

Initialize StreamLayer

In your Application class:

import android.app.Application
import io.streamlayer.sdk.StreamLayer

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        StreamLayer.initializeApp(
            context = this,
            apiKey = "YOUR_SDK_API_KEY"
        )
    }
}

Register in AndroidManifest.xml:

<application
    android:name=".MyApplication"
    ...>

Add the Fragment to Your Activity

In your main Activity:

import androidx.appcompat.app.AppCompatActivity
import io.streamlayer.sdk.ui.StreamLayerFragment

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val fragment = StreamLayerFragment()
        supportFragmentManager.beginTransaction()
            .replace(R.id.container, fragment)
            .commit()
    }
}

Add container to activity_main.xml:

<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Run Your App

# Build and run via Android Studio or:
./gradlew installDebug

You should now see the StreamLayer Element on your screen.

Related