จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
gpg::AndroidInitialization
#include <android_initialization.h>
AndroidInitialization มีฟังก์ชันเริ่มต้น 3 ฟังก์ชัน โดยต้องเรียกใช้ 1 รายการเท่านั้น
สรุป
ในกรณีที่เป็นกิจกรรม Java มาตรฐาน ควรใช้ JNI_OnLoad ในกรณีของ NativeActivity ที่จะไม่มีการเรียก JNI_OnLoad ควรใช้ android_main หรือ ANativeActivity_onCreate ระบบจะใช้ android_main เมื่อสร้าง NativeActivity โดยใช้ android_native_app_glue.h ระบบจะใช้ ANativeActivity_onCreate เมื่อสร้าง NativeActivity โดยใช้เพียง Native_activity.h android_native_app_glue.h และ Native_activity.h เป็นส่วนหัวเริ่มต้นของ Android
ต้องมีการเรียกใช้ฟังก์ชันเริ่มต้นที่เหมาะสม 1 ครั้งก่อนที่จะมีการเรียกเมธอดอินสแตนซ์ AndroidPlatformConfiguration และจะต้องเรียกใช้ก่อนที่จะสร้างอินสแตนซ์ GameServices ได้รับอนุญาตให้สร้างอินสแตนซ์ AndroidPlatformConfiguration ก่อนการเรียกการเริ่มต้นอย่างใดอย่างหนึ่ง (เช่น หากออบเจ็กต์การกำหนดค่ามีขอบเขตรวม) ตราบใดที่ไม่มีการเรียกเมธอดก่อนการเรียกการเริ่มต้น ต้องเรียกวิธีการเหล่านี้เพียงครั้งเดียวตลอดอายุของโปรแกรมการโทร ไม่ใช่ 1 ครั้งต่อออบเจ็กต์ GameServices ที่สร้างขึ้น
ฟังก์ชันสาธารณะแบบคงที่
|
ANativeActivity_onCreate(ANativeActivity *native_activity, void *savedState, size_t savedStateSize)
|
void
เมื่อใช้บริการเกมของ Play กับ NativeActivity ซึ่งอิงตาม Native_activity.h เท่านั้น ควรมีการเรียกใช้ ANativeActivity_onCreate ในช่วง ANativeActivity_onCreate ของกิจกรรมก่อนการเรียกบริการเกมของ Play ในครั้งอื่นๆ
|
JNI_OnLoad(JavaVM *jvm)
|
void
เมื่อใช้บริการเกมของ Play กับกิจกรรม 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 กับ NativeActivity ซึ่งอิงตาม Native_activity.h เท่านั้น ควรมีการเรียกใช้ ANativeActivity_onCreate ในช่วง ANativeActivity_onCreate ของกิจกรรมก่อนการเรียกบริการเกมของ Play ในครั้งอื่นๆ
JNI_OnLoad
void gpg::AndroidInitialization::JNI_OnLoad(
JavaVM *jvm
)
เมื่อใช้บริการเกมของ Play กับกิจกรรม 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."]]