2012-05-25 35 views
0

我是黑莓應用程序開發的新手。我試圖在我的應用程序中檢索來電號碼,並且使用Blackberry曲線設備和Blackberry touch模擬器正常工作,但是在運行在BlackBerry模擬器這個應用粗體9000顯示「運行時異常」和「錯誤啓動:符號PhoneCall.getPhoneNumber沒有找到」像這樣的,這裏是我的代碼,符號PhoneCall.getPhoneNumber在BlackBerry Bold 9000模擬器中找不到

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

PhoneCall .getPhoneNumber()已添加到OS 4.7中。您BlackBerry 9000模擬器可能運行OS 4.6,所以這種方法不存在。使用的最佳替代方法是PhoneCall.getDisplayPhoneNumber(),但如果號碼與設備聯繫人列表中的任何用戶都不匹配,則該號碼將僅爲您提供電話號碼。當號碼與聯繫人匹配時,您將獲得聯繫人姓名。