我的应用程序有这个类:
应用程序从Web服务(.net)检索链接列表,我使用KSoap Library(作为参考项目)。
我使用JDE 4.5进行开发,因为使用Eclipse我无法使用ListField类的方法“setRowHeight(index,int)”,那么我需要使用JDE 4.5
好的,我编译应用程序(F7键),并在模拟器(F5键)中运行。 在模拟器中,转到图标应用程序,并尝试打开......没有任何事情...应用程序未打开...很奇怪...没有错误消息(ScreenApp.java第57行)...但是......如果我再多几分钟......我看到错误信息(ScreenApp.java第57行)......我想也许是因为应用尝试连接......
后来...我认为是因为在模拟器中不存在互联网连接(我在模拟器的顶部看到EDGE ......很奇怪),我停止de模拟器,打开MDS,再次运行模拟器(F5键) ,现在有效...列表显示正确...我可以在黑莓浏览器中打开链接。
现在......我将所有已编译的文件放在同一目录中,创建一个ALX文件:
有人帮帮我吗?
答案 0 :(得分:0)
当应用程序在设备上运行时,您需要在URL的末尾使用Different connection参数。
对于前。如果是wifi,您需要在网址末尾添加; interface = wifi“。
详细代码是:您需要根据设备网络调用getConnectionString()来获取连接sufix。我希望这能解决你的问题。
/**
* @return connection string
*/
static String getConnectionString()
{
// This code is based on the connection code developed by Mike Nelson of AccelGolf.
// http://blog.accelgolf.com/2009/05/22/blackberry-cross-carrier-and-cross-network-http-connection
String connectionString = null;
// Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable.
if(DeviceInfo.isSimulator())
{
// logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is true");
connectionString = ";deviceside=true";
}
// Wifi is the preferred transmission method
else if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
{
// logMessage("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)
{
//logMessage("Carrier coverage.");
String carrierUid = getCarrierBIBSUid();
if(carrierUid == null)
{
// Has carrier coverage, but not BIBS. So use the carrier's TCP network
// logMessage("No Uid");
connectionString = ";deviceside=true";
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS request
// logMessage("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)
{
// logMessage("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)
{
//logMessage("There is no available connection.");
}
// In theory, all bases are covered so this shouldn't be reachable.
else
{
//logMessage("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.
*/
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;
}