04-12-2012 11:40 PM
How to write program for the speakerphone activate if your phone incoming then automatically answer with the speakerphone?
Solved! Go to Solution.
04-13-2012 12:43 AM - edited 04-13-2012 12:44 AM
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;
04-14-2012 12:00 AM
Thanks for a response.
That looks like what I was looking for.
Thanks a lot.
04-16-2012 06:05 AM
If the solution is helps you click the "THUMB SYMBOL" and click accept it as solution;