From 6177cb73e3d842acdd47ca3163c7c055bbcaa926 Mon Sep 17 00:00:00 2001 From: Marvin Liu Date: Fri, 24 Jun 2022 13:35:14 -0700 Subject: [PATCH] feat: add button to kotlin example to send custom event --- .../java/com/amplitude/android/sample/MainActivity.kt | 7 ++++++- .../src/main/res/layout/activity_main.xml | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainActivity.kt b/samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainActivity.kt index b828576e..ae370cd5 100644 --- a/samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainActivity.kt +++ b/samples/kotlin-android-app/src/main/java/com/amplitude/android/sample/MainActivity.kt @@ -1,6 +1,7 @@ package com.amplitude.android.sample import android.os.Bundle +import android.widget.Button import androidx.appcompat.app.AppCompatActivity import com.amplitude.core.events.EventOptions import com.amplitude.core.events.Identify @@ -14,6 +15,8 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + val sendEventButton: Button = findViewById(R.id.button) + // set user properties val identify = Identify() identify.set("user-platform", "android") @@ -41,6 +44,8 @@ class MainActivity : AppCompatActivity() { amplitude.revenue(revenue) // track event with event properties - amplitude.track("test event properties", mapOf("test" to "test event property value"), options) + sendEventButton.setOnClickListener { + amplitude.track("test event properties", mapOf("test" to "test event property value"), options) + } } } diff --git a/samples/kotlin-android-app/src/main/res/layout/activity_main.xml b/samples/kotlin-android-app/src/main/res/layout/activity_main.xml index 109b1ab9..e5f37ee6 100644 --- a/samples/kotlin-android-app/src/main/res/layout/activity_main.xml +++ b/samples/kotlin-android-app/src/main/res/layout/activity_main.xml @@ -7,6 +7,7 @@ tools:context=".MainActivity"> +