Reputation: 1454
I have an Activity which launches Dialer with specified number. After the user finishes the call, it will return to my activity. How should I get the information of the call that the user made. ie Call duration ..
Upvotes: 0
Views: 1830
Reputation: 3936
Yes, check the call logs. You can easily access this. Do something like,
Define, public Cursor mCallCursor;
Then define the fields you want to obtain from the call log,
public static final String[] STR_FIELDS = {
android.provider.CallLog.Calls.NUMBER,
android.provider.CallLog.Calls.TYPE,
android.provider.CallLog.Calls.CACHED_NAME,
android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
android.provider.CallLog.Calls.DATE,
android.provider.CallLog.Calls.DURATION, android.provider.CallLog.Calls.CACHED_NUMBER_LABEL,android.provider.CallLog.Calls.NUMBER
};
Set the order, public static final String STR_ORDER = android.provider.CallLog.Calls.DATE + " DESC";
Call the cursor.
mCallCursor = getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI,
STR_FIELDS,
null,
null,
STR_ORDER);
Upvotes: 3
Reputation: 36484
Take a look at the CallLogs.Calls class and this tutorial. See if these help.
Upvotes: 0