0

我是黑莓应用程序开发的新手。我正在尝试在我的应用程序中检索来电号码,并且它在黑莓曲线设备和黑莓触摸模拟器上运行良好,但是在 BlackBerry Simulator Bold 9000 上运行此应用程序时,它显示“运行时异常”和“错误开始:Symbol PhoneCall.getPhoneNumber is not found”这样,这是我的代码,

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.

  }
}

谁能帮我?

4

1 回答 1

1

PhoneCall.getPhoneNumber() was added in OS 4.7. You BlackBerry 9000 simulator is likely running OS 4.6, so this method isn't present. The best alternative to use is PhoneCall.getDisplayPhoneNumber() but that will only give you the phone number if the number doesn't match any user in the device contact list. When the number matches a contact, you will get the contact name instead.

于 2012-05-27T20:43:16.857 回答