Android的:如何检测私人电话编程私人、电话、Android

2023-09-07 15:04:30 作者:酷的没边儿

我用广播接收器截获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);

在私人号码的情况下,我对两个设备进行测试,它显示为-1 HTC野火和-2银河S.我查了android.telephony.PhoneNumberUtils的数目,但它便无法帮助我。

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.

有一个函数或检测的Andr​​oid手机上的私人号码一个通用的方法?谢谢

Is there a function or a generic way to detect a private number on Android phone? Thanks

推荐答案

您pretty多回答了你自己的问题。私人号码被发送到电话为-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.