用于 Android 的 Unity 中的 IMEI [英] IMEI in Unity for Android

查看:59
本文介绍了用于 Android 的 Unity 中的 IMEI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 Unity 中找到适用于 Android 的 IMEI 吗?

Can i find the IMEI for Android in Unity?

我找到了 Unity 的 Android_ID 示例:

I found an example for the Android_ID for Unity:

AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject> ("currentActivity");
AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject> ("getContentResolver");  
AndroidJavaClass secure = new AndroidJavaClass ("android.provider.Settings$Secure");
string android_id = secure.CallStatic<string> ("getString", contentResolver, "android_id");

我可以用这个方法找到IMEI并修改这个代码吗??

Can i find the IMEI with this method and modify this code??

我还在 Eclipse 中找到了用于查找 IMEI 代码的代码.

I found also the code in Eclipse to find the IMEI code.

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String IMEI = tm.getDeviceId();

谁能帮忙?谢谢!

推荐答案

在 Android 上您可以获得手机的 IMEI 通过使用

On Android you can get the phone's IMEI by using

string imei = SystemInfo.deviceUniqueIdentifier;

请注意,这需要 android.permission.READ_PHONE_STATE设置为真.如果此权限不可用,则标识符将是不同的.

Note that this requires the android.permission.READ_PHONE_STATE to be set to true. If this permission is not available, the identifier will be a different one.

这篇关于用于 Android 的 Unity 中的 IMEI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆