StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build();
StrictMode.setThreadPolicy(policy);
我尝试了以下代码,但为找不到 ThreadPolicy 的类生成异常
#if UNITY_ANDROID
using (AndroidJavaClass strictModeClass = new AndroidJavaClass("android.os.StrictMode"))
{
using (AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy"))
{
AndroidJavaObject Builder = threadpolicy.Call<AndroidJavaObject>("Builder");
AndroidJavaObject permitall = Builder.Call<AndroidJavaObject>("permitAll");
AndroidJavaObject build = permitall.Call<AndroidJavaObject>("build");
strictModeClass.Call<AndroidJavaObject>("setThreadPolicy", build);
}
}
#endif