1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c
index b1d2728..acbe515 100644
--- a/firmware/target/hosted/android/lcd-android.c
+++ b/firmware/target/hosted/android/lcd-android.c
@@ -46,15 +46,8 @@ static bool display_on;
 void connect_with_java(JNIEnv* env, jobject fb_instance)
 {
     JNIEnv e = *env;
-    /* Update RockboxFramebuffer_instance */
-    if (!e->IsSameObject(env, RockboxFramebuffer_instance, fb_instance)) {
-        if (RockboxFramebuffer_instance != NULL)
-            e->DeleteGlobalRef(env, RockboxFramebuffer_instance);
-
-        RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance);
-    }
-
     static bool have_class;
+
     if (!have_class)
     {
         jclass fb_class = e->GetObjectClass(env, fb_instance);
@@ -123,6 +116,8 @@ Java_org_rockbox_RockboxFramebuffer_surfaceCreated(JNIEnv *env, jobject this,
                                                      jobject surfaceholder)
 {
     (void)surfaceholder;
+    /* Update RockboxFramebuffer_instance */
+    RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance);
     /* possibly a new instance - reconnect */
     connect_with_java(env, this);
     display_on = true;