if (callbacks.onDestroy != NULL) {
callbacks.onDestroy(this);
}
- if (env != NULL && clazz != NULL) {
+ if (env != NULL) {
+ if (clazz != NULL) {
env->DeleteGlobalRef(clazz);
+ }
+ if (javaAssetManager != NULL) {
+ env->DeleteGlobalRef(javaAssetManager);
+ }
}
if (messageQueue != NULL && mainWorkRead >= 0) {
messageQueue->getLooper()->removeFd(mainWorkRead);
int mainWorkRead;
int mainWorkWrite;
sp<MessageQueue> messageQueue;
+
+ // Need to hold on to a reference here in case the upper layers destroy our
+ // AssetManager.
+ jobject javaAssetManager;
};
void android_NativeActivity_finish(ANativeActivity* activity) {
code->sdkVersion = sdkVersion;
+ code->javaAssetManager = env->NewGlobalRef(jAssetMgr);
code->assetManager = assetManagerForJavaObject(env, jAssetMgr);
if (obbDir != NULL) {