Open1

[Unity]AndroidのBuild情報を取得したい

sukedonsukedon

android.os.Buildクラスの情報をAndroidJavaClass経由で取得するのが早い
https://developer.android.com/reference/android/os/Build
https://docs.unity3d.com/ja/current/ScriptReference/AndroidJavaClass.htmle

using UnityEngine;
using System;
using System.Text;
using UnityEngine.UI;

public class AndroidBuildCnecker : MonoBehaviour
{
    [SerializeField] private Text _text = default;

    private void Start()
    {
        _text.text = Java.GetBuildInfo();
    }
}

public class Java
{
    public static string GetBuildInfo()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            using (var class_ = new AndroidJavaClass("android.os.Build"))
            {
                sb.AppendLine("==MODEL==");
                sb.AppendLine(class_.GetStatic<string>("MODEL"));
                sb.AppendLine("==HARDWARE==");
                sb.AppendLine(class_.GetStatic<string>("HARDWARE"));
                sb.AppendLine("==PRODUCT==");
                sb.AppendLine(class_.GetStatic<string>("PRODUCT"));
                sb.AppendLine("==FINGERPRINT==");
                sb.AppendLine(class_.GetStatic<string>("FINGERPRINT"));
                sb.AppendLine("==MANUFACTURER==");
                sb.AppendLine(class_.GetStatic<string>("MANUFACTURER"));
                return sb.ToString();
            }
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
            return e.Message + sb.ToString();
        }
    }
}