Skip to content

Commit 80260a7

Browse files
authored
Prevent Util.activity reference from being nullified. (#404)
1 parent d3178b7 commit 80260a7

File tree

1 file changed

+8
-2
lines changed
  • modules/util/src/main/native/android/dalvik

1 file changed

+8
-2
lines changed

modules/util/src/main/native/android/dalvik/Util.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Gluon
2+
* Copyright (c) 2020, 2024, Gluon
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -47,9 +47,9 @@ public class Util {
4747
private static boolean debug = false;
4848

4949
public Util(Activity activity) {
50-
Util.activity = activity;
5150
Log.v(TAG, "Util <init>");
5251
if (activity != null) {
52+
Util.activity = activity;
5353
new Handler(Util.activity.getMainLooper()).postDelayed(new Runnable() {
5454

5555
@Override
@@ -97,6 +97,9 @@ private static void syncClipboardFromOS() {
9797
@Override
9898
public void run() {
9999
if (Util.activity == null) {
100+
if (debug) {
101+
Log.v(TAG, "Util::syncClipboardFromOS failed, no activity");
102+
}
100103
return;
101104
}
102105
new Handler(Util.activity.getMainLooper()).postDelayed(new Runnable() {
@@ -123,6 +126,9 @@ public void run() {
123126

124127
private static void syncClipboardToOS() {
125128
if (Util.activity == null) {
129+
if (debug) {
130+
Log.v(TAG, "Util::syncClipboardToOS failed, no activity");
131+
}
126132
return;
127133
}
128134
final String text = nativeSyncClipboardToOS();

0 commit comments

Comments
 (0)