android sms sender name returns null

六月ゝ 毕业季﹏ 提交于 2019-12-11 01:35:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!