Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Průvodce řešením problémů Strana 189

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 286
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 188
189
12: Using the phone 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();
PhoneCallLogID participant = new PhoneCallLogID(“5551234”);
_timeSpokenTo = 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) o;
if ( phoneCallLog.getParticipant() == participant)
timeSpokenTo += phoneCallLog.getDuration();
} else {
conferencePhoneCallLog = (ConferencePhoneCallLog) o;
int participants = conferencePhoneCallLog.numberOfParticipants();
for (int j = 0; j < participants; j++)
if (conferencePhoneCallLog.getParticipantAt(j) == participant) {
timeSpokenTo += conferencePhoneCallLog.getDuration();
j = participants;
}
}
}
return timeSpokenTo;
}
}
Zobrazit stránku 188
1 2 ... 184 185 186 187 188 189 190 191 192 193 194 ... 285 286

Komentáře k této Příručce

Žádné komentáře