Android: get call history of contact

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:44:49

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