Android:如何以编程方式检测私人号码
我使用 BroadcastReceiver 在 Android 手机上拦截来电,如下所示
tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Bundle bundle = intent.getExtras();
String number = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
在“私人号码”情况下,我在两台设备上进行了测试,它在 HTC Wildfire 上显示号码为 -1,在 Galaxy S 上显示为 -2。我检查了 android .telephony.PhoneNumberUtils
但它无法帮助我。
Android 手机上有检测私人号码的功能或通用方法吗?
I use BroadcastReceiver to intercept incoming call on Android phone as below
tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Bundle bundle = intent.getExtras();
String number = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
In the "private number" case, I tested on two devices, it shows the number as -1 on HTC Wildfire and -2 on Galaxy S. I checked the android.telephony.PhoneNumberUtils
but it could't help me.
Is there a function or a generic way to detect a private number on Android phone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你几乎回答了你自己的问题。私人号码以 -1 或 -2 形式发送到电话。在我的应用程序中,我检查是否有小于 0 的整数值,如果是,我将其视为私人数字。这听起来也像是您想做的。
我希望我的想法有帮助。
You pretty much answered your own question. Private numbers are sent to the phone as -1 or -2. In my app I check for an integer value that is less than 0 and if it is, I treat it as a private number. This sounds like what you want to do as well.
I hope my thoughts are helpful.