图像正在模拟器上加载,但未加载到Blackberry设备上

图像正在模拟器上加载,但未加载到Blackberry设备上,blackberry,blackberry-simulator,Blackberry,Blackberry Simulator,我使用以下代码从服务器下载图像 公共位图connectServerForImage(字符串url){ HttpConnection HttpConnection=null; DataOutputStream httpDataOutput=null; InputStream httpInput=null; int rc; 位图bitmp=null; 试一试{ httpConnection=(httpConnection)连接器.open(url+ConnectionType.getConnecti

我使用以下代码从服务器下载图像

公共位图connectServerForImage(字符串url){
HttpConnection HttpConnection=null;
DataOutputStream httpDataOutput=null;
InputStream httpInput=null;
int rc;
位图bitmp=null;
试一试{
httpConnection=(httpConnection)连接器.open(url+ConnectionType.getConnectionType());
rc=httpConnection.getResponseCode();
if(rc!=HttpConnection.HTTP\u确定){
抛出新的IOException(“HTTP响应代码:”+rc);
}
httpInput=httpConnection.openInputStream();
InputStream Input=httpInput;
字节[]b=IOUtilities.streamToBytes(inp);
EncodedImage hai=EncodedImage.createEncodedImage(b,0,b.length);
返回hai.getBitmap();
}捕获(例外情况除外){
System.out.println(“URL位图错误…”+ex.getMessage());
}最后{
试一试{
if(httpInput!=null)
httpInput.close();
if(httpDataOutput!=null)
httpDataOutput.close();
if(httpConnection!=null)
httpConnection.close();
}捕获(例外e){
e、 printStackTrace();
}
}
返回bitmp;
}
ConnetionType类如下所示

公共类连接类型{
公共静态字符串getConnectionType()
{        
字符串连接字符串=null;
if(DeviceInfo.isSimulator())
{
connectionString=“”;
返回连接字符串;
}         
else if(WLANInfo.getWLANState()==WLANInfo.WLAN\u STATE\u CONNECTED)
{
connectionString=“;接口=wifi”;
返回连接字符串;
}         
else if((CoverageInfo.getcoveragentatus()&CoverageInfo.COVERAGE\u DIRECT)==CoverageInfo.COVERAGE\u DIRECT)
{
字符串carrierUid=getCarrierBIBSUid();
if(carrierUid==null)
{               
connectionString=“;deviceside=true”;
返回连接字符串;
} 
其他的
{
connectionString=carrierUid;
返回连接字符串;
}
}           
else if((CoverageInfo.getcoveragentatus()&CoverageInfo.COVERAGE\u MDS)==CoverageInfo.COVERAGE\u MDS)
{
connectionString=“;deviceside=false”;
返回连接字符串;
}           
其他的
{
connectionString=“;deviceside=true”;
返回连接字符串;
]           
}
/**
*查看手机的服务手册,查找运营商提供的围嘴
*网络
*
*@返回用于连接到该网络的UID。
*/
私有静态字符串getCarrierBIBSUid()
{
ServiceRecord[]records=ServiceBook.getSB().getRecords();
int电流记录;
对于(currentRecord=0;currentRecord=0)
{
//否则,使用UID构造有效的载体BIB-S
字符串carrierUid=records[currentRecord].getUid();
字符串扩展名=“;deviceside=false;connectionUID=“+carrierUid+”;ConnectionType=mds public”;
返回扩展;
}
}           
}
对于(currentRecord=0;currentRecord
图像在模拟器上显示良好,但当我在我的设备上运行时,没有显示图像。请建议我缺少的位置。
谢谢!!!

您能澄清故障是什么以及故障发生在哪里吗?我假设它在“rc=httpConnection.getResponseCode()”语句中超时,在这种情况下,您应该检查您的getConnectionType()方法并确保它提供了正确的后缀。@Peter:代码中没有错误。程序在模拟器上成功运行并显示图像。但当我在设备上运行它时,程序也成功运行,但此时没有显示图像。我想您得到了问题所在。检查您是否得到了f hai.getBitmap()或否。@DineshChandra.设备上的代码出现故障。请确保它。是的,代码在模拟器上运行,但在模拟器上getConnectionType()返回“”这是正确的,因为您正在使用MDS模拟器运行。请停止MDS模拟器并尝试您的代码-我怀疑您会看到相同的问题。然后在设备上进行调试,以确定处理在代码中的何处中断。获得此信息后立即报告。请在问题中包含有关哪个操作系统版本的信息在您的设备和模拟器上。哪种型号是您的设备和模拟器?您在设备和模拟器上使用哪种网络连接(WiFi、BES、Direct TCP等)?当代码在一个平台上工作时,而不是在另一个平台上工作时,您应该始终包含此类信息。