从 url 编码图像不起作用
在我的黑莓应用程序中,所有屏幕的底部都有广告图像(横幅图像)。
在模拟器应用程序中工作正常,但当我在 Strom 2 (9550) 应用程序中安装应用程序时,无需横幅图像即可正常工作。
我从我的网络服务获取所有横幅图像 URL,但是当我尝试对 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);
提前致谢!
In my blackberry application All screen have Ad image at the bottom of the screen (Banner image) .
In Simulator application working fine but when i install app in my Strom 2 (9550) application work fine without Banner image .
i get all Banner image URL from my web service but when i tried to encode image from URL for Display in screen i cant encode image from url so apps not looks good.
see my below code for encode image
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);
Thanks in Advance !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了这个的答案。当我们通过 wifi 使用互联网时,我们必须通过
:interface
我将此参数添加到我的图像网址中,一切正常。
i got the ans for this . when we use internet using wifi than we have to pass
:interface
i add the this parameter to my image url and all works fine .