我正在尝试查找来电的网络和 SIM 运营商,但我找不到,我的代码只能找到我设备的网络和 SIM 运营商。
这是我的代码:
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
name = phoneNumber;
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = telephonyManager.getNetworkOperatorName();
String simOperator = telephonyManager.getSimOperatorName();
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
Cursor cursor = context.getContentResolver().query(uri, new String[]{PhoneLookup.DISPLAY_NAME},null,null,null);
if (cursor.moveToFirst())
{
name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
}
欢迎任何帮助。