BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-06-2008, 03:06 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Intercept Incoming Phone Call

Please Login to Remove!

Hello all,

I am trying to write an app which overrides the automatic BlackBerry behavior and displays a screen of its own when the user receives a phone call.

My class extends AbstractPhoneListener and overrides the incomingCall() method. However, nothing I put into the incomingCall() method seems to work - I've tried pushing a new screen on, popping up a dialog, and using Status.show(). I've run through the debugger, and know it is executing the code inside the method - print statements will print out, for example.

I'm thinking that my attempts to do things with the UI are being overridden by the BlackBerry's screen that it pops up when a user receives a call. Does anybody know anything more about this? I've been looking through the api and forums, but haven't found an answer yet.

Thanks in advance!
Offline  
Old 06-09-2008, 01:41 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can try to call requestForeground
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-09-2008, 01:01 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the suggestion to use requestForeground() - when this is used the UI calls I make are actually made. I've also found that using pushGlobalScreen has similar results. However, with both of these approaches, I still run into the problem of the default BlackBerry incoming call screen covering up my screens, and the screen I've pushed onto the stack is only visible until after the user has hung up or ignored the call. I have tried using the GLOBAL_MODAL parameter and setting the priority to 0 when calling pushGlobalScreen, but changing these parameters don't seem to make a difference.

Thank you very much for your suggestion, while it didn't solve my problem, it did help me immensely and gave me ideas of other areas of the API to look through. If you have any other ideas, feel free to voice them! In the meanwhile I will look for more information about this.. I will post any solutions that I find.

The most ideal approach would to be able to modify the already existing incoming call screen to display additional information, rather than having to create a new one. From what I have read though, this is not possible.
Offline  
Old 06-10-2008, 03:10 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

would be a bit dirty but you could launch a timertask onunexposed which requestsforeground every timeframe.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-10-2008, 12:38 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much! Though I agree that it is a bit dirty, it's solved a very important problem in the app I'm working on. I can't thank you enough. :D

Also, I think you mean onObscured() rather than onunexposed...
Offline  
Old 06-11-2008, 08:44 AM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2008
Model: 8300
PIN: N/A
Carrier: O2
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Strange that pushGlobalScreen with GLOBAL_MODAL didn't work. I had this exact problem yesterday with the Phone application overriding my Dialog box after an incoming call disconnects. Found that using pushGlobalScreen with GLOBAL_MODAL worked (tried first with 1 of my screens which worked, then changed it to a dialog box). Should stay there until the user does something with it, unless the incomingCall somehow has more priority than callDisconnect which I was using.

Here's the code that I used - note that this is inside a global event catcher inside my main program and is fired by my phonelistener as it was the only way to get around another problem I was having.

Code:
Dialog d = new Dialog( Dialog.D_YES_NO, "Record Time?", 1, Bitmap.getPredefinedBitmap(Bitmap.QUESTION), 0);
            
pushGlobalScreen(d, 0, UiEngine.GLOBAL_MODAL);

switch (d.getSelectedValue())
{
    case Dialog.YES:
        requestForeground();
}
(As my app is a background process that's also selectable from the ribbon I use requestForeground() if they click yes to bring my applications activate() into action so that it pops 1 of my screens up.)

Last edited by ilh3- : 06-11-2008 at 08:55 AM.
Offline  
Old 06-11-2008, 09:05 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The method that I am using actually doesn't work... even if you comment out requestForeground() it leaves my screen on top, which makes me believe it is just trapped in the run() method of the timer task. I can't receive events from any listeners, either. Oh well, it was worth a try.

I was originally trying to use pushGlobalScreen with GLOBAL_MODAL, but it didn't seem to work, even though in onObscured I was requested the foreground. I will give it a try again though.. maybe I was missing something. Thanks!
Offline  
Old 06-11-2008, 09:51 AM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Trying pushGlobalScreen or your code results in an IllegalStateException now.. interesting, but not very useful unfortunately. I've also tried grabbing the the event lock (Application.getEventLock()), but that doesn't work either.
Offline  
Old 06-12-2008, 10:05 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have found a solution to my problem, and thought I'd post it in case someone else was trying to do the same thing. It's hacky, but better than nothing for now. Basically in my phone listener I have:

Code:
public void callIncoming(int callId)
{ 				
         UiApplication.getUiApplication().pushGlobalScreen(new Screen2(), 0, UiEngine.GLOBAL_MODAL);		
}
And then in in the Screen2 class I override onObscured:

Code:
protected void onObscured(){
	Screen activeScreen = TestListener.getUiApplication().getActiveScreen();		
	activeScreen.getUiEngine().suspendPainting(true);
	TestListener.getApplication().requestForeground();
}
I pop off my screen once the user has answered or ignored the call:

Code:
protected void onExposed(){		
	TestListener.getUiApplication().popScreen(this);
}
And to get the the UI to repaint again once the user has answered or ignored the call, in the phone listener I put:

Code:
public void callAnswered(int arg0) {		
	Screen activeScreen = TestListener.getUiApplication().getActiveScreen();
	if(activeScreen.getUiEngine().isPaintingSuspended()){
		activeScreen.getUiEngine().suspendPainting(false);
	}			
	activeScreen.doPaint();
}

I also put that bit of code in the callbacks for callFailed and callDisconnected.
There is probably still some tweaking I'm going to do - like put in checks to make sure the phone app is the screen on top when i suspend painting, and I'm not sure I really need to call doPaint() and requestForeground() in some places, or which of the callbacks I need to put it in, but it seems to be working fairly well, with no strange behavior other than that the screen which lists missed/made calls pops up afterwards.

Thanks everyone who took the time to reply and make suggestions.
Offline  
Old 06-13-2008, 01:01 AM   #10 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Location: Chennai
Model: 8130
PIN: N/A
Carrier: AIRTEL
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to disconnect the Out going call?.....

Hi,

I am developing an smart dialer app for fully automated functionality to global calling card. If the user dials a number from his contact list then immediately that number is disconnected and a new number should dial at that time..
Example if i dial 123, the phone cuts this and dial 321 or some other number...
How can i do it? Waiting for the reply ASAP....
__________________
Jayaseelan.V
Mobile Application Developer
INDIA.
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.