diff --git a/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/MainActivity.java b/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/MainActivity.java index aa718618d..52fca3063 100644 --- a/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/MainActivity.java +++ b/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/MainActivity.java @@ -80,6 +80,22 @@ public void logCaughtEx() { // [END crash_log_caught_ex] } + public void logCaughtExWithCustomKeys() { + // [START crash_log_caught_ex_custom_keys] + try { + methodThatThrows(); + } catch (Exception e) { + CustomKeysAndValues keysAndValues = new CustomKeysAndValues.Builder() + .putString("string key", "string value") + .putBoolean("boolean key", true) + .putFloat("float key", Float.MAX_VALUE) + .build(); + FirebaseCrashlytics.getInstance().recordException(e, keysAndValues); + // handle your exception here + } + // [END crash_log_caught_ex_custom_keys] + } + public void forceACrash() { // [START crash_force_crash] Button crashButton = new Button(this); diff --git a/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/kotlin/MainActivity.kt b/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/kotlin/MainActivity.kt index b07dcd69e..2c78a904e 100644 --- a/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/kotlin/MainActivity.kt +++ b/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/kotlin/MainActivity.kt @@ -77,6 +77,21 @@ class MainActivity : AppCompatActivity() { // [END crash_log_caught_ex] } + fun logCaughtExWithCustomKeys() { + // [START crash_log_caught_ex_custom_keys] + try { + methodThatThrows() + } catch (e: Exception) { + Firebase.crashlytics.recordException(e) { + key("string key", "string value") + key("boolean key", true) + key("float key", Float.MAX_VALUE) + } + // handle your exception here + } + // [END crash_log_caught_ex_custom_keys] + } + fun forceACrash() { // [START crash_force_crash] val crashButton = Button(this)