BlackBerry 应用程序开发者指南 第二卷:高级--第6章 访问电话应用程序 |
|
| 作者:佚名 来源:本站整理 发布时间:2008-3-15 1:38:34 | |
删除一个呼叫记录
>调用 PhoneLogs.deleteCall().
代码实例
下面的代码实例计算某个给定的参与者拨打电话的时间. 例: 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.*; import java.lang.*; import com.rim.samples.docs.baseapp.*; import net.rim.device.api.system.Application; public class PhoneLogsDemo extends Application { private PhoneLogs _logs; private int _timeSpokenTo; static public void main(String[] args) { PhoneLogsDemo app = new PhoneLogsDemo(); app.enterEventDispatcher(); } private PhoneLogsDemo() { _logs = PhoneLogs.getInstance(); PhoneLogsDemo phoneLogsDemo = new PhoneLogsDemo(); PhoneCallLogID participant = new PhoneCallLogID("5551234"); _timeSpokenTo = phoneLogsDemo.findTimeSpokenTo(participant, PhoneLogs.FOLDER_NORMAL_CALLS); } // Returns the number of seconds spent on the phone with a participant. public int findTimeSpokenTo(PhoneCallLogID participant, long folder) { int numberOfCalls = this._logs.numberOfCalls(folder); int timeSpokenTo = 0; PhoneCallLog phoneCallLog; ConferencePhoneCallLog conferencePhoneCallLog; for (int i = 0; i < numberOfCalls; i++) { Object o = _logs.callAt(i, folder); if (o instanceof PhoneCallLog) { phoneCallLog = (PhoneCallLog)_logs.callAt(i, folder); if ( phoneCallLog.getParticipant() == participant) timeSpokenTo += phoneCallLog.getDuration(); } else { conferencePhoneCallLog = (ConferencePhoneCallLog)_logs.callAt(i, folder); int participants = conferencePhoneCallLog.numberOfParticipants(); for (int j = 0; j < participants; j++) if (conferencePhoneCallLog.getParticipantAt(j) == participant) { timeSpokenTo += conferencePhoneCallLog.getDuration(); j = participants; } } } return timeSpokenTo; } } |
|
| [] [返回上一页] [打 印] | |
文章评论 |
|
