[英]How to get android device id?
How to get android device id? 如何获取Android设备ID? I don't know whats the "context". 我不知道什么是“上下文”。
import android.content.Context;
import android.provider.Settings;
public class getDeviceID {
public void getAndroidID(Context context) {
String android_id= Settings.System.getString(context.getContentResolver(),
Settings.Secure.ANDROID_ID);
System.out.println(android_id);
}
}
Create context for you application like this 像这样为您的应用程序创建上下文
private Context context = this;
Put this lines inside onCreate 将此行放在onCreate中
String android_id = Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ANDROID_ID);
Toast.makeText(context, "android_id= " + android_id, Toast.LENGTH_LONG).show();
And to know more about context
refer this link 要了解有关context
更多信息,请参考此链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.