通过仿真器发送电话号码 [英] send phone number through emulator

查看:129
本文介绍了通过仿真器发送电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个应用程序,我想检索设备的电话号码,发送到服务器上。但我在测试Android模拟器这个应用程序。任何人都可以请告诉我如何设置或获取在模拟器和实际设备的电话号码。

I am making an application and I want to retrieve the device phone number and send that on the server. But I am testing this application on android emulator. Can anybody please tell me how to set or get the phone number in emulator and actual device.

感谢。

推荐答案

我们可以在模拟器的电话号码,如果我们用电话经理

We can get the phone number in emulator if we use the Telephony manager

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String phone = tm.getLine1Number();

    Toast toast = Toast.makeText(getApplicationContext(), phone, Toast.LENGTH_SHORT);
    toast.show();

在使我们得到这样的电话号码的电话号码的土司..
15555215554

On making the toast of the phone number we get the phone number like.. 15555215554

这也需要android.permission.READ_PHONE_STATE许可。
因此,仿真器也有自己的电话号码。

It also need the android.permission.READ_PHONE_STATE permission. So Emulator is also having its own phone number.

这篇关于通过仿真器发送电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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