安卓模拟器有电话号码吗?
我正在开发一个客户端-服务器 Android 应用程序,并试图找出如何明确识别服务器的不同手机/用户。 我的第一次尝试是使用 SIM 卡上的电话号码。 尽管现在我想起来了,现在当您更换运营商时,您的电话号码发生变化有多常见? 我想这取决于国家/地区等。
无论如何,我一直在试图弄清楚,因为我没有实际的 Android 手机,如何更改模拟器手机的电话号码来模拟不同的用户。 是否有可能或者我应该考虑其他识别方式?
I'm working on a client-server Android application and trying to figure out how to identify different phones/users to the server unambiguously. My first attempt would be to use the phone number on the SIM card. Although now that I think about it, how common is it these days that your phone number changes when you e.g. change carrier? I guess it depends from country to country etc.
Anyway, I've been trying to figure out, since I don't have actual Android phones, how to change the phone number of the emulator phone to simulate different users. Is it possible or should I just think about alternative ways of identification?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
android_id
应该唯一标识设备,但是,有人指出,如果您知道如何 欺骗 android_id在模拟器中,
android_id
没有值,因此您需要放入调试例程来自己分配值。但是,如果您想识别用户,并让用户使用一个用户 ID 从不同设备访问您的服务,您最好为他们分配一个用户 ID,并让他们使用此用户 ID 作为凭据来对您的服务进行身份验证。 这将使他们可以在许多不同的设备上使用他们的 id,除非您将其与
android_id
结合使用(并且android_id
没有被欺骗),那么您可以将它们限制为一台设备。The
android_id
is supposed to uniquely identify the device, however, it has been noted that the id can be changed if you know how Spoofing android_idIn the emulator, the
android_id
does not have a value, so you will need to put a debugging routine in to assign a value yourself.However, if you want to identify the user, and let the user access your service from different devices with one user id you are better off assigning them a user id and having them authenticate to your service using this user id as their credential. This would let them use their id's on many different devices, unless you used it in conjunction with the
android_id
(and theandroid_id
wasn't spoofed) then you could limit them to one device.您应该使用模拟器提供的号码。 例如。 通常,正在运行的第一个模拟器的编号为 5554,第二个模拟器的编号为 5555,依此类推。
您可以使用这些号码拨打电话,在模拟器之间发送短信。 我认为,这可以根据您的目的模拟不同的数字/用户。
You should use the number present by the emulator. Eg. usually first emulator that is running has number 5554, second 5555, and so on.
You can use these numbers to make calls, send text messages from emulator to emulator. This, I think, simulates different numbers/users for your purposes.
SIM 卡信息被硬编码到 emulator-arm 和 emulator-x86 二进制文件中。 本博客文章末尾详细介绍了更改电话号码 (MSISDN):新链接,网络存档
SIM 卡存储电话号码,每 2 位数字交换一次。 因此(电话号码的前 7 位)
1555521
在二进制文件中变为515525%d1
。 虽然有点乏味,但为每个测试修补它并不是世界末日。 您还可以使用 sed:这会将号码更改为 1-876-543-[端口号]。 有关原因的详细信息请参阅链接的博客文章。
The SIM card info is hard-coded into the emulator-arm and emulator-x86 binaries. Changing the phone number (MSISDN) is detailed at the end of this blog post: new link, web archive
The SIM card stores the phone number with each 2 digits swapped. So (the first 7 of the phone number)
1555521
becomes515525%d1
in the binary. While a little tedious, patching it for each test isn't the end of the world. You could also use sed:That will change the number to 1-876-543-[PORT NUMBER]. Details on why are in the linked blog post.