Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

PhoneLogs.callAt() threw NullPointerException

Hi all,

 

I just encountered a weird phenomena

 

net.rim.blackberry.api.phone.phonelogs.PhoneLogs.callAt(int index, long folderID) threw a NullPointerException.

 

This is the code:

 

 

fPhoneLogsInstance = PhoneLogs.getInstance();
    
int numberOfPhonelogs = fPhoneLogsInstance.numberOfCalls(PhoneLogs.FOLDER_NORMAL_CALLS);
for (int i = 0; i < numberOfPhonelogs; i++)
{
  try
  {
    PhoneCallLog callLog = (PhoneCallLog)fPhoneLogsInstance.callAt(i, PhoneLogs.FOLDER_NORMAL_CALLS);
    // do some calc on the log.
  }
  catch (Exception ex)
  {
    System.out.println("Will skip FOLDER_NORMAL_CALLS phonelog entry number: " + i + " of total count: " + numberOfPhonelogs + "; Ex: " + ex.toString());
  }
}

 

 

and this is the output :

 

 

Will skip FOLDER_NORMAL_CALLS phonelog entry number: 428 of total count: 430; Ex: java.lang.NullPointerException
Will skip FOLDER_NORMAL_CALLS phonelog entry number: 429 of total count: 430; Ex: java.lang.NullPointerException

I guess last two logs somehow got broken !?

Anyone has an idea what could have gone wrong?

 

BTW, the issue occurred on a BB Bold device. It is (obviously) very hard to reproduce on another device.

 



"Listen carefully, I shall say this only once"
Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: PhoneLogs.callAt() threw NullPointerException

the code seems to be correct. if you don't manipulate the call log in your code or another thread it seems to be a bug.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: PhoneLogs.callAt() threw NullPointerException

No, I don't manipulate the phonelogs in this app.

 

But I am using other apps that are messing with the phonelogs.

 

But the strange thing is there is no way to debug this issue Smiley Sad  (especially not on device)

 

That means that such logs are skipped, and I just have to live with this.

I'll never know which entry corresponds to the two in question ... but at least my app will be more robust by using the (otherwise) unnecessary try/catch.

 

Thanks for your input simon.

 

Cheers



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: PhoneLogs.callAt() threw NullPointerException

Strangest thing...

 

Now on every boot-up the system throws an NullPointerException (not from any of 4rd party apps)

 

I guess that native phonelog (part of the native phone app) also encounters this error as my app does.

 

 

If I could only find the criminal that messed up the logs Smiley Happy



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: PhoneLogs.callAt() threw NullPointerException

I have found the log causing the error.

 

I cannot delete it Smiley Sad and no error is thrown.

The history shows two entries:

 

1) blank !?

2) date, Status: received call, duration....

 

The 1) messes up the system.

 

I will watch out for logs like this from now on, in the meantime, does anyone know how to copletely reset the phonelog ?



"Listen carefully, I shall say this only once"
Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: PhoneLogs.callAt() threw NullPointerException

no idea. i guess wiping the device would help Smiley Happy

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: PhoneLogs.callAt() threw NullPointerException

Right on champ  ! Man Tongue

 

Kidding, I will try that approach if all else fails.

 

Thanks all.

 

Not exactly sure where to put the solution.... since there is none Smiley Happy



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: PhoneLogs.callAt() threw NullPointerException

A follow up ...

 

There is an option in DM (using v5.0.1) to delete Phone logs

 

Go to: DM->Backup and restore->Advanced.

 

In the right pane there is a 'Device databases' list. Search for is a 'Phone call logs' entry and press 'Clear'.

Voila !

 

Clearing it that way removed the messed up entries.

 



"Listen carefully, I shall say this only once"