Retrieve call information by using call logs
Call information on
a
BlackBerry® device is recorded in the call logs which can
be accessed from the messages list. The call logs are stored in call log
folders that you can access by using the
PhoneLogs.FOLDER_NORMAL_CALLS or
PhoneLogs.FOLDER_MISSED_CALLS constants.
-
Import the required classes.
import net.rim.blackberry.api.phone.phonelogs.*;
-
Invoke
getInstance() to retrieve an instance of the call
log.
PhoneLogs _logs = PhoneLogs.getInstance();
-
Invoke
numberOfCalls() to retrieve the total number of
calls in a specified call log folder (FOLDER_MISSED_CALLS or
FOLDER_NORMAL_CALLS).
int numberOfCalls = _logs.numberOfCalls(PhoneLogs.FOLDER_NORMAL_CALLS);
-
Invoke
PhoneLogs.callAt() to retrieve call information from
a call log, passing in the index for the call log, and the call log folder.
PhoneCallLog phoneLog = (PhoneCallLog)_logs.callAt(0,PhoneLogs.FOLDER_NORMAL_CALLS);
-
Invoke
PhoneCallLog.getType() to retrieve the call type.
The possible return values are
TYPE_MISSED_CALL_OPENED,
TYPE_MISSED_CALL_UNOPENED,
TYPE_PLACED_CALL, or
TYPE_RECEIVED_CALL.
int phoneType = phoneLog.getType();
Was this information helpful? Send us your comments.