playgameservices / cpp-android-basic-samples

Sample games using the Google Play Games C++ SDK
303 stars 131 forks source link

Incorrect advice in android_support.h file from SDK. #57

Open stolk opened 5 years ago

stolk commented 5 years ago

In the gpg-cpp-sdk v 3.0.1 there is a file android/include/gpg/android_support.h

This file mentions:

* <h1>Example code for an Android 4.0+ game using a Java Activity</h1>
 * In your Java Activity, please add the following. You may need to merge this
 * code with your existing lifecycle functions.
 * \code
 * public class YourActivity extends Activity {
 *   protected void onActivityResult(int requestCode,
 *                                   int resultCode,
 *                                   Intent data) {
 *     super.onActivityResult(requestCode, resultCode, data);
 *     nativeOnActivityResult(this, requestCode, resultCode, data);
 *   }
 *
 *   // Implemented in C++.
 *   private static native void nativeOnActivityResult(
 *       Activity activity,
 *       int requestCode,
 *       int resultCode,
 *       Intent data);
 * }
 * \endcode
 * Then, in your native library, add the following forwarding functions.
 * \code
 * void Java_com_example_yourapp_YourActivity_nativeOnActivityResult(
 *     JNIEnv* env,
 *     jobject thiz,
 *     jobject activity,
 *     jint request_code,
 *     jint result_code,
 *     jobject data) {
 *   gpg::AndroidSupport::OnActivityResult(
 *       env, activity, request_code, result_code, data);
 * }
 * \endcode

These code snippets are incorrect.

The Java part of the code defines a static function, without a 'thiz' pointer.

The C part of the code defines a non static function, with a 'thiz' pointer.

These do not rhyme.

Causing android studio to warn:

image

Please address, @hak