BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-12-2009, 05:51 AM   #1 (permalink)
New Member
 
Join Date: Feb 2009
Model: 9500
PIN: N/A
Carrier: F Bouygues Telecom
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default PhoneLogListener problem

Please Login to Remove!

Hi,

First, I precise that I'm sorry if something similar was already posted, but I can't find it out in this forum.

Second, I precise that I'm new to Java AND to BB dev, so I'm sorry if my problem seems to be verry stupid

Then, My goal is to made an app that runs into the background, but with an UI, and I want my app to do things on some CallLogs events. I see that is being possible, using PhoneLogs.addListener() and overload some method in a class that implements PhoneLogListener.

So, let's explain what I did:

I am trying to add a PhoneLogs listener, but I can't figure out how to solve it out !

I tryed many different implementations (described below), and none of them works.

For testing purpose, I tryed 2 types of alert to check if the methods where executed:
- updating text of a RichTextField: only exemple2 permits to do this, but I got a JavaException
the first time an action was made on the PhoneLogs (incoming call), and then, the second call
freeze completely the simulator.

exemple1: adding the "implements PhoneLogListener" in the class that extends UiApplication:
public class MyLogApp extends UiApplication implements PhoneLogListener{
static public void main(String[] args) {
MyLogApp app = new MyLogApp();
app.enterEventDispatcher();
PhoneLogs.addListener(app);
}
and then I use System.out.println to or .err in the methods overloaded, but I can't see
anything.

is this implementation the right way to catch PhoneLog events ?


exemple2 "implements PhoneLogListener" in the class that extends MainScreen:
Here I can use MyRichText.insert(); to add some text when the overloaded functions are
triggered, but the first time I got a java exception, but the text is updated, and the
second event freeze the simulator.

I called addListener at the end of the MyLogAppScreen class constructor, like this:
PhoneLogs.addListener(this);

exemple3:
same as exemple 2 but using a subclass of my MainScreen class, that implements PhoneLogListener,
and then I call PhoneLogs.addListener(new MyPhoneListener()); at the last line of the MainScreen
constructor.

exemple4: in the UiApplication class, but calling PhoneLogs.addListener(app); right before
the enterEventDispatcher();

exemple5: same, but without the enterEventDispatcher(); at all !

My question is: is one of the examples the right way to do what I want to do, and, why nothing
happens ?

Best Regards,
Strato
__________________
___________________
Best regards,
Strato
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.