Google Play 遊戲電腦版提供標準的 Android 執行階段環境,除了必須加入 x86 或 x86-64 二進位檔,其餘遊戲封裝步驟都與行動版一樣。如果可以,電腦版應使用與行動版相同的 APK 或應用程式套件。
若行動版和 Google Play 遊戲電腦版都用一樣套件,最好偵測是否使用鍵盤,在執行階段啟用 Google Play 遊戲電腦版專屬功能:
Kotlin
val hasKeyboard = resources.configuration.keyboard == KEYBOARD_QWERTY
Java
boolean hasKeyboard = getResources().getConfiguration().keyboard == KEYBOARD.QWERTY
C#
var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
var resources = currentActivity.Call<AndroidJavaObject>("getResources");
var configuration = resources.Call<AndroidJavaObject>("getConfiguration");
var keyboard = configuration.Get<int>("keyboard");
var hasKeyboard == 2; // Configuration.KEYBOARD_QWERTY
您也可以檢查 "com.google.android.play.feature.HPE_EXPERIENCE"
系統功能:
Kotlin
var isPC = packageManager.hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE")
Java
PackageManager pm = getPackageManager(); boolean isPC = pm.hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE")
C#
var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); var packageManager = currentActivity.Call<AndroidJavaObject>("getPackageManager"); var isPC = packageManager.Call<bool>("hasSystemFeature", "com.google.android.play.feature.HPE_EXPERIENCE");