-
-
Android C++如何获取ANDROID_ID
-
-
Android C++如何获取ANDROID_ID
可以通过adb获取ANDROID_ID
adb shell settings get secure android_id
根据根据网上的代码,封装了个执行命令并获取返回值的函数,但是执行settings get secure android_id不能获取到返回值,但是可以执行其他命令,比如获取网卡MAC cat /sys/class/net/wlan0/address
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | string MySystem(string cmd)
{
FILE * fstream = NULL;
char buff[ 1024 ];
memset(buff, 0 , sizeof(buff));
string ret = "";
if (NULL = = (fstream = popen(cmd.c_str(), "r" )))
{
fprintf(stderr, "execute command failed: %s" , strerror(errno));
return "-2" ;
}
while (NULL ! = fgets(buff, sizeof(buff), fstream))
{
ret.append(buff).append( "\n" );
}
pclose(fstream);
if (ret.length() = = 0 )
{
return "-1" ;
}
return ret;
}
|
请教是否有其他获取ANDROID_ID的方法,或者我这种获取方式如何处理能正常获取到ANDROID_ID
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!