Когда Run Code auid равен null :( Пожалуйста, помогите мне.
код Android здесь ---------------------------------------------------------
Код Android
public class UnityPlugin{
@RequiresApi(api = Build.VERSION_CODES.O)
public String GetDeviceId(Activity mActivity)
{
// Get the device ID
String auid = "";
Context context = mActivity.getApplicationContext();
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if(tm != null)
{
try{
auid = tm.getImei();
}
catch (SecurityException e){
e.printStackTrace();
}
}
return auid;
}
}
Код C # здесь --------------------------------------------------
C # Код:
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext");
Plugin = new AndroidJavaObject("com.unityplugin.PluginLibrary.UnityPlugin");
txtIMEI.text = Plugin.Call<string>("GetDeviceId", activity);