我们有一个使用XML在8900 BB设备上加载数据的应用程序。一切都在模拟器上运行良好,所有相关的数据加载。但是在设备上我们得到一个黑色的页面,没有任何负载任何人都可以帮我们找到问题吗?也许那是因为我们没有签署申请?
我们设法在设备网络设置中设置APN后才加载数据。所有本机和下载的应用程序之前都没有任何APN设置,为什么我们的应用程序在没有APN的情况下加载数据呢?
答案 0 :(得分:2)
不幸的是,对此的“回答”是“BlackBerry上的网络很难”。不过,有一些相当不错的资源可以让你快速达到速度。以下是开发人员论坛上关于建立网络连接以及完成任务的各种不同方法的精彩帖子:
此外,一位有经验的黑莓开发者发布了一个非常好的实用工具类,您可能希望尝试使用它来更多地防止连接:
http://www.versatilemonkey.com/blog/index.php/2009/06/24/networking-helper-class/
答案 1 :(得分:0)
我知道这个帖子已经被关闭了,但是考虑到有人在那里需要它。这个问题确实减慢了我几个小时的开发时间,所以我认为它适合分享。我将提供两种方法来帮助检查设备并使用适当的传输方式。要使用此方法,只需调用getConnectionString方法并附加到url字符串的末尾,就可以了。
//the method returns the connection string
public String getConnectionString()
{
String connectionString = "";
if(DeviceInfo.isSimulator())
{
if(true)// toggle between true and false to enable simulator use mds
{
// Log.i(TAG, "Device is a simulator and USE_MDS_IN_SIMULATOR is true");
connectionString = ";deviceside=false";
}
else
{
// Log.i(TAG, "Device is a simulator and USE_MDS_IN_SIMULATOR is false");
connectionString = ";deviceside=true";
}
}
// Wifi is the preferred transmission method
else if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
{
// Log.i(TAG, "Device is connected via Wifi.");
connectionString = ";interface=wifi";
}
// Is the carrier network the only way to connect?
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
{
// Log.i(TAG, "Carrier coverage.");
String carrierUid = getCarrierBIBSUid();
if(carrierUid == null)
{
// Has carrier coverage, but not BIBS. So use the carrier's TCP network
// Log.i(TAG, "No Uid");
connectionString = ";deviceside=true";
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS request
// Log.i(TAG, "uid is: " + carrierUid);
connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
}
}
// Check for an MDS connection instead (BlackBerry Enterprise Server)
else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
{
// Log.i(TAG, "MDS coverage found");
connectionString = ";deviceside=false";
}
// If there is no connection available abort to avoid bugging the user unnecssarily.
else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
// Log.i(TAG, "There is no available connection.");
}
// In theory, all bases are covered so this shouldn't be reachable.
else
{
// Log.i(TAG, "no other options found, assuming device.");
connectionString = ";deviceside=true";
}
return connectionString;
}
/**
* Looks through the phone's service book for a carrier provided BIBS network
* @return The uid used to connect to that network. This is called from getConnectionString()
*/
private 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;
}
样本用法如下:
String url = "specific url"+getConnectionString();
HttpConnection connection = (HttpConnection)Connector.open( url, Connector.READ, true );
这种方法是完整的证明,已经在多个设备上进行了测试,所以我想在这里用简洁的格式。 祝你好运