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
New Contributor
Posts: 2
Registered: ‎12-24-2009
My Device: Not Specified
Accepted Solution

How to activate the speakerphone using the api?

How to write program for the speakerphone activate if your phone incoming then automatically answer with the speakerphone?

Highlighted
Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: How to activate the speakerphone using the api?

[ Edited ]

Try this Sample Code:

 

 For this in your Application there is a file named "BlackBerry_App_Descriptor.xml"  select the checkbox of "autorun on startup" then no need to click the application seperately; 

 

Below is my StartUp class

 

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

public final class StartUp extends Application 
{		
	
	public static void main(String args[])
	{
		new StartUp().enterEventDispatcher();
	}
	public StartUp() 
	{		
		Phone.addPhoneListener(new PhoneCallListner());
		System.out.println("============== Phone Listener Activated");
	}	
}

 and the PhoneListener class is:

 

public class PhoneCallListner extends AbstractPhoneListener
{
	private boolean isIncoming=false;
	
	public void callConnected(int callId) 
	{	
		super.callConnected(callId);
		if(isIncoming)
			activateSpeakerPhone();	
	}
	
	public void callIncoming(int callId) 
	{
		super.callIncoming(callId);
		isIncoming=true;
	}

	private void activateSpeakerPhone() 
	{
		isIncoming=false;
		String str="Activate Speakerphone";
		Screen screen=Ui.getUiEngine().getActiveScreen();
		Menu menu=screen.getMenu(0);
		for(int i=0;i<menu.getSize();i++)
		{
			if(menu.getItem(i).toString().equalsIgnoreCase(str))
			{
				menu.getItem(i).run();//Here it activate the speaker Phone;				
			}			
		}	
	}	
}

This works as when the incoming call is occur then only it activates the speakerPhone otherwise not; If you want for OutGoing also then remove the "isIncoming" variable;

 

Try this one;

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
New Contributor
Posts: 2
Registered: ‎12-24-2009
My Device: Not Specified

Re: How to activate the speakerphone using the api?

 Thanks for a response.


That looks like what I was looking for.

 

Thanks a lot.

Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: How to activate the speakerphone using the api?

If the solution is helps you click the "THUMB SYMBOL" and click accept it as solution;

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.