Skip to content

Commit 49cc55d

Browse files
Merge fc20d26 into be45a71
2 parents be45a71 + fc20d26 commit 49cc55d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/ScreenshotEventProcessor.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.sentry.Hint;
1818
import io.sentry.SentryEvent;
1919
import io.sentry.SentryLevel;
20+
import io.sentry.util.HintUtils;
2021
import io.sentry.util.Objects;
2122
import java.io.ByteArrayOutputStream;
2223
import java.io.Closeable;
@@ -51,10 +52,18 @@ public ScreenshotEventProcessor(
5152
application.registerActivityLifecycleCallbacks(this);
5253
}
5354

55+
public void setCurrentActivity(@NonNull Activity activity) {
56+
if (currentActivity != null && currentActivity.get() == activity) {
57+
return;
58+
}
59+
currentActivity = new WeakReference<>(activity);
60+
}
61+
5462
@SuppressWarnings("NullAway")
5563
@Override
5664
public @NotNull SentryEvent process(final @NotNull SentryEvent event, @NotNull Hint hint) {
57-
if (!lifecycleCallbackInstalled) {
65+
if (!lifecycleCallbackInstalled
66+
|| !HintUtils.shouldApplyScopeData(hint)) {
5867
return event;
5968
}
6069
if (!options.isAttachScreenshot()) {
@@ -167,13 +176,6 @@ private void cleanCurrentActivity(@NonNull Activity activity) {
167176
}
168177
}
169178

170-
private void setCurrentActivity(@NonNull Activity activity) {
171-
if (currentActivity != null && currentActivity.get() == activity) {
172-
return;
173-
}
174-
currentActivity = new WeakReference<>(activity);
175-
}
176-
177179
@SuppressLint("NewApi")
178180
private boolean isActivityValid(@Nullable Activity activity) {
179181
if (activity == null) {

0 commit comments

Comments
 (0)