1
在我的黑莓應用程序中所有屏幕都在屏幕底部有廣告圖像(橫幅圖像)。對URL進行編碼無法正常工作
在模擬器應用程序工作正常,但是當我安裝應用程序在我的Strom 2(9550)應用程序工作正常沒有橫幅圖像。
我從我的網絡服務獲取所有橫幅圖像網址,但是當我試圖從URL中對圖像進行編碼以顯示屏幕時,我無法編碼來自url的圖像,所以應用看起來不好。
看我下面的代碼編碼圖像
connection = (HttpConnection) Connector.open(bannerImage[i], Connector.READ, true);
inputStream = connection.openInputStream();
byte[] responseData = new byte[10000];
int length = 0;
StringBuffer rawResponse = new StringBuffer();
while (-1 != (length = inputStream.read(responseData)))
{
rawResponse.append(new String(responseData, 0, length));
}
int responseCode = connection.getResponseCode();
if (responseCode != HttpConnection.HTTP_OK)
{
throw new IOException("HTTP response code: "
+ responseCode);
}
final String result = rawResponse.toString();
byte[] dataArray = result.getBytes();
encodeImageBitmap = EncodedImage.createEncodedImage(dataArray, 0, dataArray.length);
先謝謝了!
那麼,究竟是什麼問題?你是否遇到異常?如果是這樣,它是什麼時候發生的?我們需要更多的細節。 –
我通過wifi使用互聯網,所以我認爲這是問題..當在網址末尾添加參數時,此代碼工作良好。 – Hitarth