我正在尝试使用以下代码来读取电话号码。但它曾经将数字返回为data1
. 如何解决此问题以获得实际数字?
minorCursor = contentResolver.query(Phone.CONTENT_URI, new String[] { Phone.NUMBER, Phone.TYPE },
" DISPLAY_NAME = '" + name + "'", null, null);
while (minorCursor.moveToNext()) {
switch (minorCursor.getInt(minorCursor.getColumnIndex(Phone.TYPE))) {
case Phone.TYPE_MOBILE:
phoneNumber = Phone.NUMBER;
break;
case Phone.TYPE_HOME:
phoneNumber = Phone.NUMBER;
break;
case Phone.TYPE_WORK:
phoneNumber = Phone.NUMBER;
break;
case Phone.TYPE_OTHER:
phoneNumber = Phone.NUMBER;
break;
}
}
我从对如何在 Android 中检索联系人姓名和电话号码的第三个响应中获得代码,因为我假设他说其他回复使用的方法已被弃用。