我为黑莓开发了一个应用程序,它得到了应用程序世界的批准,但它给出了以下错误
on 4.6
Critical tunnel failure
和
on 5.0 and 6.0
ava.io APN not specified
请帮助为什么会出现此错误以及如何解决它
我认为问题是您没有向 url 添加适当的连接后缀。
点击链接可以解决您的问题:http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is_-_Different_ways_to_make_an_HTTP_or_socket_connection.html?nodeid=826935&vernum=0
并且还可以使用以下示例代码:
private static String getConnectionString(){
String connectionString="";
if(WLANInfo.getWLANState()==WLANInfo.WLAN_STATE_CONNECTED){
connectionString=";interface=wifi";
}
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS){
connectionString = ";deviceside=false";
}
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT)==CoverageInfo.COVERAGE_DIRECT){
String carrierUid=getCarrierBIBSUid();
if(carrierUid == null) {
connectionString = ";deviceside=true";
}
else{
connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
}
}
else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
}
return connectionString;
}
只是为了澄清一些问题。
@Jisson你的回答很有帮助
但是您没有包含方法getCarrierBIBSUid()的代码
/**
* Looks through the phone's service book for a carrier provided BIBS network
* @return The uid used to connect to that network.
*/
private static String getCarrierBIBSUid()
{
ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;
for(currentRecord = 0; currentRecord < records.length; currentRecord++)
{
if(records[currentRecord].getCid().toLowerCase().equals("ippp"))
{
if(records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0)
{
return records[currentRecord].getUid();
}
}
}
return null;
}
此外,包括以下内容可能会有所帮助
if (DeviceInfo.isSimulator()){
return ";deviceSide=true";
}
在 getConnectionString() 方法的开头有关更多信息,请参阅 Melick 的博客
通过自行设置手机上的 APN 值并使用其他答案中建议的连接字符串代码解决了此问题。
更改您的 APN 设置(在南非)
On Home screen, click Options
Click Advanced Options and then TCP
Enter the APN: **internet**
username: **guest**
password: **guest**
Press the Menu key and select Save
(对于世界其他地区,请在此处找到您的设置)从 http://www.blackberrytune.com/blackberry-tcp-ip-apn-settings/和http://www.blackberryfaq.com/index.php/Carrier_specific_APN/TCP_settings