קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
gpg::AndroidInitialization
#include <android_initialization.h>
AndroidInitialization כוללת שלוש פונקציות אתחול, וצריך לקרוא לאחת מהן בדיוק.
סיכום
במקרה של פעילות Java רגילה, יש להשתמש ב-JNI_OnLoad. במקרה של NativeActivity שבו לא תתבצע קריאה ל-JNI_OnLoad, יש להשתמש ב-android_main או ב-ANativeActivity_onCreate. משתמשים ב-android_main כשמפתחים NativeActivity באמצעות android_native_app_glue.h. כדי ליצור פעילות NativeActivity, משתמשים ב-ANativeActivity_onCreate. android_native_app_glue.h ו-Native_activity.h הן כותרות של Android כברירת מחדל.
יש לקרוא לפונקציית האתחול המתאימה בדיוק פעם אחת לפני קריאה ל-methods של AndroidPlatformConfiguration, וצריך להפעיל אותה לפני יצירת אובייקט GameServices. מותר ליצור מופע של AndroidPlatformConfiguration לפני אחת מהקריאות לאתחול (לדוגמה, אם לאובייקט ההגדרה יש היקף גלובלי), כל עוד לא מתבצעת קריאה ל-methods לפני הקריאה לאתחול. צריך לקרוא לשיטות האלה רק פעם אחת בכל משך החיים של תוכנת השיחות, ולא פעם אחת לכל אובייקט GameServices שנוצר.
פונקציות סטטיות ציבוריות
|
ANativeActivity_onCreate(ANativeActivity *native_activity, void *savedState, size_t savedStateSize)
|
void
כשמשתמשים בשירותי Play Games עם פעילות NativeActivity שמבוססת רק עלnative_activity.h, יש להפעיל את ANativeActivity_onCreate במהלך ANativeActivity_onCreate של הפעילות שלכם, לפני כל שיחה אחרת של Play Games Services.
|
JNI_OnLoad(JavaVM *jvm)
|
void
כשמשתמשים ב-Play Games Services עם פעילות Java רגילה, יש לקרוא ל-JNI_OnLoad כשמתבצעת קריאה ל-JNI_OnLoad של הספרייה הדינמית.
|
android_main(struct android_app *app)
|
void
כשמשתמשים בשירותי משחקים של Play עם NativeActivity שמבוסס על android_native_app_glue.h, יש לקרוא ל-android_main במהלך ה-android_main של הפעילות שלך, לפני כל קריאה אחרת של שירותי המשחקים של Play.
|
פונקציות סטטיות ציבוריות
ANativeActivity_onCreate
void gpg::AndroidInitialization::ANativeActivity_onCreate(
ANativeActivity *native_activity,
void *savedState,
size_t savedStateSize
)
כשמשתמשים בשירותי Play Games עם פעילות NativeActivity שמבוססת רק עלnative_activity.h, יש להפעיל את ANativeActivity_onCreate במהלך ANativeActivity_onCreate של הפעילות שלכם, לפני כל שיחה אחרת של Play Games Services.
JNI_OnLoad
void gpg::AndroidInitialization::JNI_OnLoad(
JavaVM *jvm
)
כשמשתמשים ב-Play Games Services עם פעילות Java רגילה, יש לקרוא ל-JNI_OnLoad כשמתבצעת קריאה ל-JNI_OnLoad של הספרייה הדינמית.
android_main
void gpg::AndroidInitialization::android_main(
struct android_app *app
)
כשמשתמשים בשירותי משחקים של Play עם NativeActivity שמבוסס על android_native_app_glue.h, יש לקרוא ל-android_main במהלך ה-android_main של הפעילות שלך, לפני כל קריאה אחרת של שירותי המשחקים של Play.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-27 (שעון 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."]]