BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-23-2007, 08:58 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default PhoneListenerProblem

Please Login to Remove!

what is whrong in this code snipet?


Code:
public void registerOnStartup() {
        Incomins_Call_Block phone_handler = new Incomins_Call_Block();
        Phone.addPhoneListener(phone_handler);        
    }
    public void deRegisterOnEnd() {
        Phone.removePhoneListener(phone_handler);
    }
i get the following error when i compile the code for text in red
"cannot find symbol"

Code:
Incomins_Call_Block phone_handler = new Incomins_Call_Block();
public void registerOnStartup() {
       
        Phone.addPhoneListener(phone_handler);        
    }
    public void deRegisterOnEnd() {
        Phone.removePhoneListener(phone_handler);
    }
and for this snipet i get a exception"net.rim.vm.StackOverflowError"

i tried doing it this also :
Code:
public void registerOnStartup(int i) {
      
       Incomins_Call_Block phone_handler = new Incomins_Call_Block();
        if(i == 1) {
            Phone.addPhoneListener(phone_handler);
        }
        else {
          //  Dialog.alert(" bye bye "); 
            Phone.removePhoneListener(phone_handler);
            phone_handler = null;
             System.exit(0);
        }
    }
but when i pass i=0....the listener does noyget removed.
can someone help.

thanks
Meenal

Last edited by Meenal : 02-24-2007 at 01:53 AM.
Offline  
Old 02-26-2007, 09:49 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I didn't work with Phone and PhoneListener and don't know why StackOverflowError happens. Maybe problem is inside Incomins_Call_Block implementation itself.

But in 1st code snippet error happens because you define variable in one method and use it in another method. In 3rd code snippet you create new Incomins_Call_Block object on every registerOnStartup() request and objects, passed to addPhoneListener() and removePhoneListener() are different objects
Offline  
Old 03-01-2007, 02:32 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I realised my mistake....and the solution would b to send the app in the background when activated .but i am new to BB programming and have yet not figured out how to do so.I know the Application call api will be usefull but have not been able to figure out use it.

Could u help me
__________________
Thanks
Meenal
Offline  
Old 03-01-2007, 04:05 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can call Application.getApplication().requestBackground() to send application to background.
But frankly speaking, I don't see how it will solve StackOverflowError problem...
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.