Android: get call history of contact

后端 未结 1 440
别跟我提以往
别跟我提以往 2020-12-19 20:36

i am using this code the get to the contact info of a contact (i am using it also - with a few modifications - to call, send sms or email the contact). I wonder if there is

相关标签:
1条回答
  • 2020-12-19 21:19

    There is a class called CallLog.Calls that contains the CONTENT_URI to query for call history.

    Here's an example listing the phone numbers in the call log:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.main);
    
        String[] projection = new String[] {
            CallLog.Calls._ID, CallLog.Calls.NUMBER};
        Cursor query = this.managedQuery(
            CallLog.Calls.CONTENT_URI, projection, null, null, null);
    
        ListAdapter adapter = new SimpleCursorAdapter(
            this, android.R.layout.simple_list_item_1, query,
            new String[] {CallLog.Calls.NUMBER},
            new int[] {android.R.id.text1});
        this.setListAdapter(adapter);
    }
    
    0 讨论(0)
提交回复
热议问题