在BlackBerry Bold 9000模拟器中找不到符号PhoneCall.getPhoneNumber

时间:2012-05-25 06:32:56

标签: blackberry

我是黑莓应用程序开发的新手。我正在尝试检索我的应用程序中的来电号码,并且使用Blackberry曲线设备和Blackberry触摸模拟器正常工作,但在BlackBerry Simulator Bold 9000上运行此应用程序时显示“运行”时间异常“和”错误启动:未找到符号PhoneCall.getPhoneNumber“这样,这是我的代码,

import java.io.IOException;
import net.rim.blackberry.api.phone.AbstractPhoneListener;
import net.rim.blackberry.api.phone.Phone;
import net.rim.blackberry.api.phone.PhoneCall;
import net.rim.device.api.system.RadioInfo;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;

/**
* This class extends the UiApplication class, providing a
* graphical user interface.
*/
public class MyApp extends UiApplication
{
/**
 * Entry point for application
 * @param args Command line arguments (not used)
 */ 
public static void main(String[] args)
{
    // Create a new instance of the application and make the currently
    // running thread the application's event dispatch thread.
    MyApp theApp = new MyApp();       
    theApp.enterEventDispatcher();
}


/**
 * Creates a new MyApp object
 */
public MyApp()
{        

    // Push a screen onto the UI stack for rendering.
    pushScreen(new HomeScreen());
    Phone.addPhoneListener(new PhoneCallInterceptor());
}    
}
final class PhoneCallInterceptor extends AbstractPhoneListener {

public PhoneCallInterceptor() {

}

public void callIncoming(final int callId) {

    final PhoneCall call = Phone.getCall(callId);  
    final String number = call.getPhoneNumber();    //Here its throws an error.

  }
}

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

PhoneCall。在OS 4.7中添加了getPhoneNumber()。您的BlackBerry 9000模拟器可能正在运行OS 4.6,因此此方法不存在。使用的最佳替代方法是PhoneCall。getDisplayPhoneNumber()但如果号码与设备联系人列表中的任何用户都不匹配,则只会为您提供电话号码。当号码与联系人匹配时,您将获得联系人姓名。