Stay organized with collections
Save and categorize content based on your preferences.
gpg::AndroidInitialization
#include <android_initialization.h>
AndroidInitialization includes three initialization functions, exactly one of which must be called.
Summary
In the case of a standard Java Activity, JNI_OnLoad should be used. In the case of a NativeActivity where JNI_OnLoad will not be called, either android_main or ANativeActivity_onCreate should be used. android_main is used when building a NativeActivity using android_native_app_glue.h. ANativeActivity_onCreate is used when building a NativeActivity using just native_activity.h. android_native_app_glue.h and native_activity.h are default Android headers.
The appropriate initialization function must be called exactly once before any AndroidPlatformConfiguration instance methods are called, and it must be called before a GameServices object is instantiated. It is permitted to instantiate a AndroidPlatformConfiguration before one of the initialization calls (for example, if the configuration object has global scope), as long as no methods are called before the initialization call. These methods need be called only once in the lifetime of the calling program, not once per GameServices object created.
Public static functions
|
ANativeActivity_onCreate(ANativeActivity *native_activity, void *savedState, size_t savedStateSize)
|
void
When using Play Game Services with a NativeActivity which is based on only native_activity.h, ANativeActivity_onCreate should be called during your activity's ANativeActivity_onCreate, before any other Play Game Services calls.
|
JNI_OnLoad(JavaVM *jvm)
|
void
When using Play Game Services with a standard Java Activity, JNI_OnLoad should be called when the dynamic library's JNI_OnLoad is called.
|
android_main(struct android_app *app)
|
void
When using Play Game Services with a NativeActivity which is based on android_native_app_glue.h, android_main should be called during your activity's android_main, before any other Play Game Services calls.
|
Public static functions
ANativeActivity_onCreate
void gpg::AndroidInitialization::ANativeActivity_onCreate(
ANativeActivity *native_activity,
void *savedState,
size_t savedStateSize
)
When using Play Game Services with a NativeActivity which is based on only native_activity.h, ANativeActivity_onCreate should be called during your activity's ANativeActivity_onCreate, before any other Play Game Services calls.
JNI_OnLoad
void gpg::AndroidInitialization::JNI_OnLoad(
JavaVM *jvm
)
When using Play Game Services with a standard Java Activity, JNI_OnLoad should be called when the dynamic library's JNI_OnLoad is called.
android_main
void gpg::AndroidInitialization::android_main(
struct android_app *app
)
When using Play Game Services with a NativeActivity which is based on android_native_app_glue.h, android_main should be called during your activity's android_main, before any other Play Game Services calls.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-10-28 UTC.
[null,null,["Last updated 2024-10-28 UTC."],[],[],null,["# gpg::AndroidInitialization Struct Reference\n\ngpg::AndroidInitialization\n==========================\n\n`#include \u003candroid_initialization.h\u003e`\n\n[AndroidInitialization](/games/services/cpp/api/struct/gpg/android-initialization#structgpg_1_1_android_initialization) includes three initialization functions, exactly one of which must be called.\n\nSummary\n-------\n\nIn the case of a standard Java Activity, JNI_OnLoad should be used. In the case of a NativeActivity where JNI_OnLoad will not be called, either android_main or ANativeActivity_onCreate should be used. android_main is used when building a NativeActivity using android_native_app_glue.h. ANativeActivity_onCreate is used when building a NativeActivity using just native_activity.h. android_native_app_glue.h and native_activity.h are default Android headers.\n\nThe appropriate initialization function must be called exactly once before any [AndroidPlatformConfiguration](/games/services/cpp/api/class/gpg/android-platform-configuration#classgpg_1_1_android_platform_configuration) instance methods are called, and it must be called before a [GameServices](/games/services/cpp/api/class/gpg/game-services#classgpg_1_1_game_services) object is instantiated. It is permitted to instantiate a [AndroidPlatformConfiguration](/games/services/cpp/api/class/gpg/android-platform-configuration#classgpg_1_1_android_platform_configuration) before one of the initialization calls (for example, if the configuration object has global scope), as long as no methods are called before the initialization call. These methods need be called only once in the lifetime of the calling program, not once per [GameServices](/games/services/cpp/api/class/gpg/game-services#classgpg_1_1_game_services) object created.\n\n| ### Public static functions ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [ANativeActivity_onCreate](#structgpg_1_1_android_initialization_1a816753e9576f07d1d58f2e94b26ad66c)`(ANativeActivity *native_activity, void *savedState, size_t savedStateSize)` | `void` When using Play Game Services with a NativeActivity which is based on only native_activity.h, ANativeActivity_onCreate should be called during your activity's ANativeActivity_onCreate, before any other Play Game Services calls. |\n| [JNI_OnLoad](#structgpg_1_1_android_initialization_1ae43182cd58941ddc74eb07535c8de97a)`(JavaVM *jvm)` | `void` When using Play Game Services with a standard Java Activity, JNI_OnLoad should be called when the dynamic library's JNI_OnLoad is called. |\n| [android_main](#structgpg_1_1_android_initialization_1ace2b90a82cc0b9ad5aeb7ac73996b100)`(struct android_app *app)` | `void` When using Play Game Services with a NativeActivity which is based on android_native_app_glue.h, android_main should be called during your activity's android_main, before any other Play Game Services calls. |\n\nPublic static functions\n-----------------------\n\n### ANativeActivity_onCreate\n\n```c++\nvoid gpg::AndroidInitialization::ANativeActivity_onCreate(\n ANativeActivity *native_activity,\n void *savedState,\n size_t savedStateSize\n)\n``` \nWhen using Play Game Services with a NativeActivity which is based on only native_activity.h, ANativeActivity_onCreate should be called during your activity's ANativeActivity_onCreate, before any other Play Game Services calls. \n\n### JNI_OnLoad\n\n```c++\nvoid gpg::AndroidInitialization::JNI_OnLoad(\n JavaVM *jvm\n)\n``` \nWhen using Play Game Services with a standard Java Activity, JNI_OnLoad should be called when the dynamic library's JNI_OnLoad is called. \n\n### android_main\n\n```c++\nvoid gpg::AndroidInitialization::android_main(\n struct android_app *app\n)\n``` \nWhen using Play Game Services with a NativeActivity which is based on android_native_app_glue.h, android_main should be called during your activity's android_main, before any other Play Game Services calls."]]