Programmatically detect if app is being run on device or simulator

前端 未结 8 1897
我寻月下人不归
我寻月下人不归 2020-11-28 06:14

I\'d like to know whether my app is being run on device or simulator at run time. Is there a way to detect this?

Reason being to test bluetooth api with simulator:

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 06:40

    if anyone is looking for Unity solution i did this, the only way i found how.

    using System.Globalization;
    
    public static bool IsArm() {
            return CultureInfo.InvariantCulture.CompareInfo.IndexOf(SystemInfo.processorType, "ARM", CompareOptions.IgnoreCase) >= 0;
        }
    

提交回复
热议问题