From c6dfded7784caeb6afcc2471a142ac52ce0ee404 Mon Sep 17 00:00:00 2001 From: Jakub Malinowski Date: Thu, 6 Jun 2024 17:35:28 +0200 Subject: [PATCH] Enable manual creation of screen view spans --- sample-app/src/main/AndroidManifest.xml | 7 ++- .../splunk/android/sample/FirstFragment.java | 15 ++++++ .../src/main/res/layout/fragment_first.xml | 6 +++ sample-app/src/main/res/values/strings.xml | 1 + .../rum/ExplicitVisibleScreenNameTracker.java | 39 +++++++++++++++ .../java/com/splunk/rum/NoOpSplunkRum.java | 7 ++- .../java/com/splunk/rum/RumInitializer.java | 14 +++++- .../main/java/com/splunk/rum/SplunkRum.java | 25 +++++++++- .../com/splunk/rum/NoOpSplunkRumTest.java | 3 ++ .../java/com/splunk/rum/SplunkRumTest.java | 48 +++++++++++++++++-- 10 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 splunk-otel-android/src/main/java/com/splunk/rum/ExplicitVisibleScreenNameTracker.java diff --git a/sample-app/src/main/AndroidManifest.xml b/sample-app/src/main/AndroidManifest.xml index bec0ab4c0..31417d5cc 100644 --- a/sample-app/src/main/AndroidManifest.xml +++ b/sample-app/src/main/AndroidManifest.xml @@ -21,10 +21,15 @@ android:exported="true"> - + + { + SplunkRum.getInstance().setScreenName("custom-screen"); + }); + binding.crash.setOnClickListener(v -> multiThreadCrashing()); binding.httpMe.setOnClickListener( @@ -184,12 +189,22 @@ public LiveData getSessionId() { public void onDestroyView() { super.onDestroyView(); binding = null; + + SplunkRum.getInstance().setScreenName(null); } @Override public void onResume() { super.onResume(); sessionId.postValue(splunkRum.getRumSessionId()); + + SplunkRum.getInstance().setScreenName("custom-resumed-name", "Resumed"); + } + + @Override + public void onPause() { + super.onPause(); + SplunkRum.getInstance().setScreenName(null); } @SuppressLint("AllowAllHostnameVerifier") diff --git a/sample-app/src/main/res/layout/fragment_first.xml b/sample-app/src/main/res/layout/fragment_first.xml index af78e301a..4267f0230 100644 --- a/sample-app/src/main/res/layout/fragment_first.xml +++ b/sample-app/src/main/res/layout/fragment_first.xml @@ -42,6 +42,12 @@ android:layout_height="wrap_content" android:text="@string/next" /> +