0

我读过很多人试图解释如何在 Android 上打开呼叫日志并允许用户选择一个项目,但他们都不起作用。有人有好的工作样本吗?

4

2 回答 2

1

以下代码片段非常适合我

Intent showCallLog = new Intent();
showCallLog.setAction(Intent.ACTION_VIEW);
showCallLog.setType(CallLog.Calls.CONTENT_TYPE);
context.startActivity(showCallLog);   
于 2013-04-03T07:53:49.360 回答
0

我使用自己的版本进行了此操作。我使用了一个对话框并将光标交给了通话记录。这是功能:

public void getCallLog() {

    String[] callLogFields = { android.provider.CallLog.Calls._ID,
            android.provider.CallLog.Calls.NUMBER,
            android.provider.CallLog.Calls.CACHED_NAME /* im not using the name but you can*/};
    String viaOrder = android.provider.CallLog.Calls.DATE + " DESC";
    String WHERE = android.provider.CallLog.Calls.NUMBER + " >0"; /*filter out private/unknown numbers */

    final Cursor callLog_cursor = getActivity().getContentResolver().query(
            android.provider.CallLog.Calls.CONTENT_URI, callLogFields,
            WHERE, null, viaOrder);

    AlertDialog.Builder myversionOfCallLog = new AlertDialog.Builder(
            getActivity());

    android.content.DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int item) {
            callLog_cursor.moveToPosition(item);

            Log.v("number", callLog_cursor.getString(callLog_cursor
                    .getColumnIndex(android.provider.CallLog.Calls.NUMBER)));

            callLog_cursor.close();

        }
    };
    myversionOfCallLog.setCursor(callLog_cursor, listener,
            android.provider.CallLog.Calls.NUMBER);
    myversionOfCallLog.setTitle("Choose from Call Log");
    myversionOfCallLog.create().show();
}
于 2013-04-22T16:11:38.877 回答