黑莓 - 从拨号程序手机应用程序运行菜单项 [英] Blackberry - run menu item from dialer Phone App

查看:167
本文介绍了黑莓 - 从拨号程序手机应用程序运行菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想描述一个把戏我在 supportforums.blackberry.com学会

I'd like to describe one trick I learned at supportforums.blackberry.com

有在黑莓原生拨号电话应用程序。

There is a native dialer Phone Application in BlackBerry.

诀窍就是来电后,以编程运行拨号菜单项,调用失败或其他任何呼叫事件。

The trick is to programmatically run menu items of dialer after incoming call, call fail or any other call event.

推荐答案

有一个<一个href=\"http://www.blackberry.com/developers/docs/4.5.0api/net/rim/blackberry/api/phone/PhoneListener.html\"相对=nofollow> PhoneListener 接口,这给听的传入和传出的电话状态的能力。

There is a PhoneListener interface, which gives an ability to listen to the status of incoming and outgoing phone calls.

请参阅监听和处理电话事件

从<甲A报价href=\"http://supportforums.blackberry.com/rim/board/message?board.id=java%5Fdev&view=by%5Fdate%5Fascending&message.id=62284#M62284\"相对=nofollow> supportforums.blackberry.com - 回复:如何退出的UI应用程序(由simon_hain):

监听由它们被添加到应用硬引用。形象地说,它们成为轮缘应用程序的一部分。

Listeners are hard referenced by the application they are added to. Figuratively speaking, they become part of the rim application.

如果您的监听器添加到该监听器在手机应用的上下文中执行的电话应用程序。

  您可以通过使用Ui.getUiEngine()的监听器方法来检查。getActiveScreen()。返回的屏幕是手机应用的呼叫屏幕。

If you add a listener to the phone application this listener is executed in the context of the phone app.
You can check this by using Ui.getUiEngine().getActiveScreen() in a listener method. The returned screen is the call screen of the phone application.

我用这个来电话执行命令:

   - 对callInitiated或callConnected我存储在手机屏幕的引用

   - 我叫phoneScreen.getMenu(0)

I use this to execute commands on phone calls:
- on callInitiated or callConnected i store a reference to the phone screen.
- i call phoneScreen.getMenu(0)

现在我想执行一个命令:

   - 我改变区域设置为en

   - 我通过菜单使用menu.getSize()和menu.getItem(I)
迭代
   - 我是否menuItem.toString等于我的命令

   - 我叫menuItem.run()

   - 修改本地化返回(如果它被改变)

now i want to execute a command:
- i change the locale to "en"
- i iterate through the menu using menu.getSize() and menu.getItem(i)
- i check if menuItem.toString equals my command
- i call menuItem.run()
- and change the locale back (if it was changed)

您可以使用此:

  静音

  取消静音

  激活免提

  鉴于speeddiallist

  结束
电话(仅前的4.5 / 4.6,不知道哪一个)
  还有很多。只打印可用的菜单项:)

you can use this to:
mute
unmute
activate speakerphone
view speeddiallist
end the call (only prior to 4.5/4.6, not sure which one)
and many more. just print the available menu items :)

一个样本code的这一招,对来电打印所有菜单到控制台上回答来电静音的手机上结束通话 - 取消静音电话:

A sample code for this trick, on incoming call print all menu to console, on answer call mute phone on end call - unmute phone:

public class UseScreenMenu extends Application implements PhoneListener {
    String MENU_ITEM_MUTE = "Mute";
    String MENU_ITEM_UNMUTE = "Unmute";
    public UseScreenMenu() {
    	Phone.addPhoneListener(this);
    }

    public static void main(String[] args) {
    	UseScreenMenu app = new UseScreenMenu();
    	app.enterEventDispatcher();
    }

    public void callIncoming(int callId) {
    	printMenu();	
    }

    public void callAnswered(int callId) {
    	runMenuItem(MENU_ITEM_MUTE);
    }

    public void callEndedByUser(int callId) {
    	runMenuItem(MENU_ITEM_UNMUTE);	
    }

    private void printMenu() {		
    	Screen screen = Ui.getUiEngine().getActiveScreen();
    	Menu menu = screen.getMenu(0);
    	System.out.println("Menu of BB Dialler - Begin");
    	for (int i = 0, cnt = menu.getSize(); i < cnt; i++)
    		System.out.println("Menu of BB Dialler - "
    			+menu.getItem(i).toString());
    	System.out.println("Menu of BB Dialler - End");		
    }

    private void runMenuItem(String menuItemText) {
    	Screen screen = Ui.getUiEngine().getActiveScreen();
    	Menu menu = screen.getMenu(0);
    	for (int i = 0, cnt = menu.getSize(); i < cnt; i++)
    		if(menu.getItem(i).toString().equalsIgnoreCase(menuItemText))
    			menu.getItem(i).run();
    }


    public void callAdded(int callId) {}
    public void callConferenceCallEstablished(int callId) {}
    public void callConnected(int callId) {}
    public void callDirectConnectConnected(int callId) {}
    public void callDirectConnectDisconnected(int callId) {}
    public void callDisconnected(int callId) {}
    public void callFailed(int callId, int reason) {}
    public void callHeld(int callId) {}
    public void callInitiated(int callid) {}
    public void callRemoved(int callId) {}
    public void callResumed(int callId) {}
    public void callWaiting(int callid) {}
    public void conferenceCallDisconnected(int callId) {}
}

这篇关于黑莓 - 从拨号程序手机应用程序运行菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆