istereo2

diff src/android/amain.c @ 29:c6c45fa9658d

fixed jni calls for ads
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Oct 2015 04:55:45 +0300
parents f0da8b2b61ec
children 900651a2f401
line diff
     1.1 --- a/src/android/amain.c	Mon Oct 05 17:16:31 2015 +0300
     1.2 +++ b/src/android/amain.c	Thu Oct 08 04:55:45 2015 +0300
     1.3 @@ -29,6 +29,7 @@
     1.4  static JavaVM *jvm;
     1.5  static JNIEnv *jni;
     1.6  static jclass activity_class;
     1.7 +static jobject activity;
     1.8  
     1.9  void android_main(struct android_app *app_ptr)
    1.10  {
    1.11 @@ -47,6 +48,7 @@
    1.12  		fprintf(stderr, "failed to attach native thread to Java VM\n");
    1.13  		exit(1);
    1.14  	}
    1.15 +	activity = app->activity->clazz;
    1.16  	activity_class = (*jni)->GetObjectClass(jni, app->activity->clazz);
    1.17  
    1.18  	for(;;) {
    1.19 @@ -88,7 +90,7 @@
    1.20  		fprintf(stderr, "failed to retrieve MainActivity.show_ad method\n");
    1.21  		return;
    1.22  	}
    1.23 -	(*jni)->CallVoidMethod(jni, activity_class, method);
    1.24 +	(*jni)->CallVoidMethod(jni, activity, method);
    1.25  }
    1.26  
    1.27  void ad_banner_hide(void)
    1.28 @@ -100,7 +102,7 @@
    1.29  		fprintf(stderr, "failed to retrieve MainActivity.hide_ad method\n");
    1.30  		return;
    1.31  	}
    1.32 -	(*jni)->CallVoidMethod(jni, activity_class, method);
    1.33 +	(*jni)->CallVoidMethod(jni, activity, method);
    1.34  }
    1.35  
    1.36  static void handle_command(struct android_app *app, int32_t cmd)