54
BlackBerry Device Applications Integration Guide
Code sample
Code sample: Calculating the time spent on the phone by a participant
Example: PhoneLogsDemo.java
/**
* PhoneLogsDemo.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
package com.rim.samples.docs.phonelogs;
import net.rim.blackberry.api.phone.phonelogs.*;
Retrieve a call participant by phone
number.
The
PhoneCallLogID
class identifies participants in a phone call log by phone number.
>
Invoke
PhoneCallLog.getParticipant(int)
or
ConferencePhoneCallLog.getParticipantAt().
PhoneCallLogID participant = phoneCallLog.getParticipant();
PhoneCallLogID participant = ConferencePhoneCallLog.getParticipant();
Retrieve the phone number type.
The P
honeCallLogID
class identifies the type of phone call for a log. For example, home, mobile,
work, or fax, as recorded in the address book.
>
Invoke
PhoneCallLogID.getType()
.
String phoneType = PhoneCallLogID.getType();
Create a call log or conference call log.
The
PhoneCallLogID
constructor removes dashes and other non-numeric characters from phone
numbers.
1.
Create an instance of a
PhoneCallLog
or
ConferencePhoneCallLog
object, and provide
the date, duration, participants, and notes for the call as parameters to the constructor.
Date date = new Date("1000"); // date of call
int duration = 60; // duration of call
PhoneCallLogID caller1 = new PhoneCallLogID("555-1234"); // first
participant
PhoneCallLogID caller2 = new PhoneCallLogID("555-1235"); // second
participant
String notes = "New call."; // notes
ConferencePhoneCallLog conferenceCall = new
ConferencePhoneCallLog(date, duration,
PhoneLogs.FOLDER_NORMAL_CALLS, caller1, caller2, notes);
2. Update the call log:
•
To update the call log, invoke
PhoneLogs.addCall(CallLog call).
_logs.addCall(conferenceCall);
•
To replace the call log with a new call log, invoke
PhoneLogs.swapCall(CallLog
call,int index,long folderID)
_logs.swapCall(conferenceCall, 0, FOLDER_NORMAL_CALLS);
Delete a call log.
>
Invoke
PhoneLogs.deleteCall().
_logs.deleteCall(0);
Task
Steps
Summary of Contents for JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Page 4: ......
Page 7: ......
Page 10: ...10 BlackBerry Device Applications Integration Guide...
Page 12: ...12 BlackBerry Device Applications Integration Guide...
Page 50: ...50 BlackBerry Device Applications Integration Guide...
Page 56: ...56 BlackBerry Device Applications Integration Guide...
Page 65: ......
Page 66: ...2008 Research In Motion Limited Published in Canada...