קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
במדריך הזה נסביר איך להעביר את המשחק שלכם כך שישתמש ב-Input SDK העדכני ביותר. ב-SDK בגרסה 1.0.0-beta יש שיפורים משמעותיים בהשוואה לגרסה הקודמת 0.0.4. מומלץ לעבור מהתצוגות המקדימות הקודמות בהקדם האפשרי. ערכת ה-SDK בגרסה 0.0.4 תמשיך לפעול עד מרץ 2023.
מעדכנים את התלות
מוחקים את הספרייה 0.0.4 מהספרייה libs כי היא זמינה עכשיו ב-Maven. לאחר מכן מוצאים את השורה הבאה בקובץ build.grade ברמת המודול:
מחליפים את extends ב-implements כדי לציין שאתם מטמיעים ממשק במקום להרחיב כיתה.
איתור המקום שבו מרחיבים את InputMappingProvider:
publicclassMyInputMapProviderextendsInputMappingProvider{@NonNull@OverridepublicInputMaponProvideInputMap(){// TODO: return an InputMap}}
ומשנים אותו כך שיוטמע InputMappingProvider:
publicclassMyInputMapProviderimplementsInputMappingProvider{@NonNull@OverridepublicInputMaponProvideInputMap(){// TODO: return an InputMap}}
שימוש ב-InputClient החדש
registerInputMappingProvider ו-unregisterInputMappingProvider הוחלפו ב-setInputMappingProvider וב-clearInputMappingProvider.
בנוסף, הפונקציה clearInputMappingProvider כבר לא מקבלת ארגומנט כך שכבר לא צריך לשמור הפניה לספק כדי לבטל את הרישום מאוחר יותר.
Kotlin
כדי לרשום את ספק מפת הקלט, מאתרים את הקריאה ל-registerInputMappingProvider:
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# Migrate to the 1.0.0-beta Input SDK\n\nThis guide describes how to migrate your game to use the latest\nInput SDK. The 1.0.0-beta SDK has substantial improvements over the\nprevious 0.0.4 preview. You should migrate from the earlier previews as soon as\npossible. The 0.0.4 SDK will continue function through March 2023.\n\nUpdate the dependency\n---------------------\n\nDelete the 0.0.4 library from your `libs` directory since the library is now\navailable on maven. Then Find this line in your module-level `build.grade`\nfile: \n\n implementation files('libs/inputmapping-0.0.4.aar')\n\nReplace it with the following code: \n\n implementation 'com.google.android.libraries.play.games:inputmapping:1.0.0-beta'\n\nImplement the new InputMappingProvider interface\n------------------------------------------------\n\nThe former abstract class `InputMappingProvider` turned into an interface in\nversion `1.0.0-beta`. The method `onProvideInputMap()` is still part of the\ninterface.\n\n\u003cbr /\u003e\n\n### Kotlin\n\n\u003cbr /\u003e\n\nRemove `()` from the class definition since there's no constructor to invoke in\n`InputMappingProvider`.\n\nLocate your `InputMappingProvider` implementation: \n\n class MyInputMapProvider : InputMappingProvider() {\n override fun onProvideInputMap(): InputMap {\n TODO(\"Not yet implemented\")\n }\n }\n\nAnd update it to this: \n\n class MyInputMapProvider : InputMappingProvider {\n override fun onProvideInputMap(): InputMap {\n TODO(\"Not yet implemented\")\n }\n }\n\n\u003cbr /\u003e\n\n### Java\n\n\u003cbr /\u003e\n\nReplace `extends` with `implements` to indicate that your implementing an\ninterface rather than extending a class.\n\nLocate where you extend `InputMappingProvider`: \n\n public class MyInputMapProvider extends InputMappingProvider {\n @NonNull\n @Override\n public InputMap onProvideInputMap() {\n // TODO: return an InputMap\n }\n }\n\nAnd change it to implement `InputMappingProvider`: \n\n public class MyInputMapProvider implements InputMappingProvider {\n @NonNull\n @Override\n public InputMap onProvideInputMap() {\n // TODO: return an InputMap\n }\n }\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUse the new InputClient\n-----------------------\n\n`registerInputMappingProvider` and `unregisterInputMappingProvider` have been\nreplaced with `setInputMappingProvider` and `clearInputMappingProvider`.\nFurther, `clearInputMappingProvider` no longer takes an argument so you no\nlonger need to keep a reference to your provider to unregister it later.\n\n\u003cbr /\u003e\n\n### Kotlin\n\nTo register your input map provider, locate your call to `registerInputMappingProvider`:\n\n\u003cbr /\u003e\n\n private val myInputMapProvider by lazy {\n MyInputMapProvider()\n }\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n val inputMappingClient = Input.getInputMappingClient(this)\n inputMappingClient.registerInputMappingProvider(myInputMapProvider)\n }\n\nAnd replace it with `setInputMappingProvider`: \n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n val inputMappingClient = Input.getInputMappingClient(this)\n inputMappingClient.setInputMappingProvider(MyInputMapProvider())\n }\n\nTo clear your input map, locate your call to `unregisterInputMappingProvider`: \n\n override fun onDestroy() {\n val inputMappingClient = Input.getInputMappingClient(this)\n inputMappingClient.unregisterInputMappingProvider(myInputMapProvider)\n\n super.onDestroy()\n }\n\nAnd replace it with `clearInputMappingprovider`: \n\n override fun onDestroy() {\n val inputMappingClient = Input.getInputMappingClient(this)\n inputMappingClient.clearInputMappingProvider()\n\n super.onDestroy()\n }\n\n\u003cbr /\u003e\n\n### Java\n\n\u003cbr /\u003e\n\nTo register your input map provider, locate your call to\n`registerInputMappingProvider`: \n\n private final MyInputMapProvider myInputMapProvider = new MyInputMapProvider();\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n InputMappingClient inputMappingClient = Input.getInputMappingClient(this);\n inputMappingClient.registerInputMappingProvider(myInputMapProvider);\n }\n\nAnd replace it with `setInputMappingProvider`: \n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n\n InputMappingClient inputMappingClient = Input.getInputMappingClient(this);\n inputMappingClient.setInputMappingProvider(new MyInputMapProvider());\n }\n\nTo clear your input mapping provider, locate your call to\n`unregisterInputMappingProvider`: \n\n @Override\n protected void onDestroy() {\n InputMappingClient inputMappingClient = Input.getInputMappingClient(this);\n inputMappingClient.unregisterInputMappingProvider(myInputMapProvider);\n\n super.onDestroy();\n }\n\nAnd replace it with `clearInputMappingProvider`: \n\n @Override\n protected void onDestroy() {\n InputMappingClient inputMappingClient = Input.getInputMappingClient(this);\n inputMappingClient.clearInputMappingProvider();\n\n super.onDestroy();\n }\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]