BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-09-2008, 05:28 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Sample Code for PhoneListener needed

Please Login to Remove!

Can someone please upload the code for PhoneListener no matter however abstract it is ?

It would be fine if it could just detect whenever a call is being made

I just want to see a working version as the samples that I have built dont detect any Phone calls at all

It would also be fine if you could send just the COD file
Offline  
Old 07-09-2008, 05:40 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

i just stripped some test application from the specific stuff, put both into the same package.

Code:
import net.rim.blackberry.api.phone.Phone;
import net.rim.device.api.system.Application;

public class OutgoingIntercept extends Application {

	/**
	 * @param args
	 */
	public static void main(String[] args) {		
		new OutgoingIntercept().enterEventDispatcher();
	}
	
	public OutgoingIntercept(){
		Phone.addPhoneListener(new OutgoingInterceptPhoneListener());
	}
Code:
import net.rim.blackberry.api.phone.AbstractPhoneListener;

public class OutgoingInterceptPhoneListener extends AbstractPhoneListener {
	
	public void callInitiated(int callId) {		
		System.out.println("initiated");
	}
}
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-09-2008, 07:31 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Simon

Thanks very much for helping

So the name of the COD file should be the same as that of the package , isn't it so ?
Offline  
Old 07-09-2008, 08:15 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

the cod name is not dependent on the package name, no.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-09-2008, 01:14 PM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Simon

Thanks for your very generous help so far

Can you please say what should be the Project properties one I have created the Java files ?

Also if I dont specify an icon , will it still be visible ?
Offline  
Old 07-09-2008, 01:49 PM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alo if I am implementing it as a simple Background listener app , would it mean that no outputs like System.out or Dialog.alert values are displayed to the user ?

Will I have to create Alternate CLDC Application Entry Point application to achieve that purpose ?
Offline  
Old 07-10-2008, 04:22 AM   #7 (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

i would suggest that you read the developer guides. 90% of your questions are covered there.

- if you don't specifiy an icon it will show a generic black icon, similar to the old DOS icons.
- if you make your project autorun (and systemmodule) it will not show an icon on the homescreen
- sysout is never shown to the user
- to interact with the UI extend UiApplication
- to show a dialog synchronize on the eventlock or use invokelater
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-10-2008, 05:54 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Simon

Can you please say which Developer Guide should I refer to ?

All the guide I referred to seems to need previous knowledge of BlackBerry devlopment

Can you specify the most basic and starting one if possible ?
Offline  
Old 07-10-2008, 07:11 AM   #9 (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

developer guides

you can also take a look at jonathans samples
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-10-2008, 11:57 AM   #10 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Simon

I had tried this sample earlier on

BlackBerry - BlackBerry | Wireless Handheld Devices, Software & Services from Research In Motion (RIM)

But I couldn't make it work for me

Can you please say what should be the Project properties for this sample ?

Shouldn't have I been able to acess those call bck methods straightforward ?
Offline  
Old 07-10-2008, 12:15 PM   #11 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Basically this is what hope you can help me with

Based on the BlackBerry - BlackBerry | Wireless Handheld Devices, Software & Services from Research In Motion (RIM) example can you please show me how a call initiated event is caught and that activity is shown back to the user

What will be the Project properties I need to set to achieve that ?
Offline  
Old 07-11-2008, 04:57 PM   #12 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7290
PIN: N/A
Carrier: Cingular
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

For that particular source, I think you need to have it run on start up. Other than that, it seems to work fine for me, I just stepped through it on the debugger. What seems to be the problem?
Offline  
Old 09-08-2008, 08:02 AM   #13 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2008
Model: 8900
OS: 4.3-4.6.1
Carrier: t-mobile
Posts: 39
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Try this

No. There is no need to set properties to 'run on startup', but in that case you will need to start the app yourself.

An example:
Code:
public class Test_01 extends Application implements PhoneListener  {
    private Screen_01 fScreen;

    public Test_01() {
        Phone.addPhoneListener(this);
        fScreen = new Screen_01();
   }

    public static void main(String[] args) {
        //create a new instance of the application
        //and start the application on the event thread
        Test_01 app = new Test_01();
        
        app.enterEventDispatcher();
        System.out.println("App started");
    }
}
// now few of the PhoneListener implementations:
//...              
public void callAnswered(int arg0) {
        System.out.println("EVENT: callAnswered");
        Ui.getUiEngine().pushGlobalScreen(fScreen, 4, UiEngine.GLOBAL_QUEUE);
    }
//...
public void callDisconnected(int arg0) {
        System.out.println("EVENT: callDisconnected");
        Ui.getUiEngine().popScreen(fScreen);
    }
//...
now create the screen:
Code:
final public class Screen_01 extends PopupScreen {
    public Screen_01() {
        super(new VerticalFieldManager());

        // you can write whatever you want, i'll just draw a bitmap :)
        Bitmap fBitmap = new Bitmap(20, 50);
        Graphics fGraphics  = new Graphics(fBitmap);
        fGraphics.drawLine(0, 0, 20, 50);
        
        add(new BitmapField(fBitmap));
    }
}
Happy coding

Last edited by myraddin : 09-08-2008 at 08:04 AM. Reason: Post method made by mistake
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.