Skip to content

Commit 63a8722

Browse files
committed
fix access to java env in jnius from the python service + save the instance of the service within a static public PythonService.mService.
1 parent 3c98016 commit 63a8722

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/jni/sdl/src/video/android/SDL_androidvideo.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,9 @@ JAVA_EXPORT_NAME(SDLSurfaceView_nativeInitJavaCallbacks) ( JNIEnv* env, jobject
151151

152152
ANDROID_InitOSKeymap();
153153
}
154+
155+
JNIEXPORT void JNICALL
156+
JAVA_EXPORT_NAME(PythonService_nativeInitJavaEnv) ( JNIEnv* env, jobject thiz )
157+
{
158+
JavaEnv = env;
159+
}

src/src/org/renpy/android/PythonService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import android.util.Log;
99
import android.app.Notification;
1010
import android.app.PendingIntent;
11-
import android.os.Process;
11+
import android.os.Process;
1212

1313
public class PythonService extends Service implements Runnable {
1414

@@ -22,6 +22,7 @@ public class PythonService extends Service implements Runnable {
2222
private String pythonPath;
2323
// Argument to pass to Python code,
2424
private String pythonServiceArgument;
25+
public Service mService = null;
2526

2627
@Override
2728
public IBinder onBind(Intent arg0) {
@@ -101,6 +102,8 @@ public void run(){
101102
} catch(UnsatisfiedLinkError e) {
102103
}
103104

105+
this.mService = this;
106+
nativeInitJavaEnv();
104107
nativeStart(androidPrivate, androidArgument, pythonHome, pythonPath,
105108
pythonServiceArgument);
106109
}
@@ -110,4 +113,6 @@ public static native void nativeStart(String androidPrivate, String androidArgum
110113
String pythonHome, String pythonPath,
111114
String pythonServiceArgument);
112115

116+
public static native void nativeInitJavaEnv();
117+
113118
}

0 commit comments

Comments
 (0)