问题
Greetings.
I am trying to read the sms sender name using the following code. The variable name is always null. Please let me know what is the problem with code. It returns address properly But the name is null
ContentResolver contentResolver = getContentResolver();
Cursor mCursor = contentResolver.query( Uri.parse( "content://sms/inbox" ), null, null, null, null);
if(mCursor.getCount()==0)
return;
startManagingCursor(mCursor);
mCursor.moveToFirst();
String fromadd = mCursor.getString(mCursor.getColumnIndex("address"));
String name = mCursor.getString(mCursor.getColumnIndex("person"));
used permissions
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
Best Regards jothi
来源:https://stackoverflow.com/questions/10812438/android-sms-sender-name-returns-null