Published July 9, 2019

The Snapchat Creative SDK (Creative Kit) for Android: Video Tutorial

Wondering how you can get started building with Creative Kit? Check out this handy video and get the basic code to start your own app.

If you’re interested in building this exact example, you can start with our official Android example app, and check out the code below:

import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.view.View
import android.view.Window
import com.snapchat.kit.sdk.SnapCreative
import com.snapchat.kit.sdk.creative.models.SnapLiveCameraContent
/**
 * Demo app's Main Activity
 */
class SPSDemoMainActivity: FragmentActivity() {
    companion object {
        private const val TAG = "SPSDemoMainActivity"
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        setContentView(R.layout.sps_demo_activity)
        val creativeKitButton = findViewById<View>(R.id.snap_share_button)
        creativeKitButton.setOnClickListener {
            val activity = this@SPSDemoMainActivity
            // Step 0 - Initialize the Creative Kit API + Media Factory.
            val creativeKit = SnapCreative.getApi(activity)
            val mediaFactory = SnapCreative.getMediaFactory(activity)
            // Step 1 - Choose your source of Media. (Snap's Camera)
            val snapLiveCameraContent = SnapLiveCameraContent()
            // Step 2 - Decide your overlays -  Caption & Sticker.
            snapLiveCameraContent.captionText = "CK Live Demo! \uD83E\uDD1E"
            // Step 2b - Configure the sticker asset to pass to Snapchat.
            val stickerFile = FileUtils.createNewFile(this, "sticker.png")
            FileUtils.writeInputStreamToFile(assets.open("snap-dev-logo.png"), stickerFile)
            val snapSticker = mediaFactory.getSnapStickerFromFile(stickerFile)
            snapSticker.setWidth(300f)
            snapSticker.setHeight(300f)
            snapSticker.setPosX(0.7f)
            snapSticker.setPosY(0.2f)
            snapSticker.setRotationDegreesClockwise(15f)
            snapLiveCameraContent.snapSticker = snapSticker
            // Step 3 - Set your attachment URL.
            snapLiveCameraContent.attachmentUrl = "https://snapkit.com"
            // Step 4 - Send!
            creativeKit.send(snapLiveCameraContent)
        
    
}

Happy building!