如何从URL加载图像中balckberry
问题描述:
可能重复:
Show Images from URL in blackberry如何从URL加载图像中balckberry
嗨想从URL中balckberry直接LAOD的图像。 balckberry没有选择直接打电话。是那里做的,所以引导我。
答
没有捷径可以这样做。 你需要通过代码来完成。
public static InputStream getInputStream(String url)
{
InputStream inputStream = null;
HttpConnection httpConnection = null;
try
{
httpConnection = (HttpConnection)Connector.open(url+connectiontype));
httpConnection.setRequestMethod(HttpConnection.POST);
final int r=httpConnection.getResponseCode();
if(r==200)
inputStream = httpConnection.openDataInputStream();
}
catch(final Exception e)
{
System.out.println("Error is "+e.getMessage());
}
return inputStream;
}
,并使用getInputStream()
这样的:
InputStream is=getInputStream(s1);
int length=is.available();
//System.out.print("length ==========="+length);
byte[] data=new byte[length];
data = IOUtilities.streamToBytes(is);
// code to save image in sd card
saveFile.create();
OutputStream outStream = saveFile.openOutputStream();
outStream.write(data);
outStream.close();
saveFile.close();
is.close();
此代码将保存从URL的形象。
答
Pramodhini请在谷歌检查您的问题后,发布您的问题。 你知道这个问题有多糟?
很多的答案可用于您的问题。点击波纹管链接你可以找到解决方案
如果你仍然没有找到,然后打开此链接
http://www.coderholic.com/blackberry-webbitmapfield/
或
http://supportforums.blackberry.com/t5/Java-Development/Display-a-web-image/m-p/351839#M65341
+0
你ok.fine和不介意我是否做错了什么。谢谢 – Pramodhini
检查我这个问题的答案-http://stackoverflow.com/questions/12049101/show-images-from-url-in-blackberry/12049139#12049139 – Signare
海感谢您的代码它只是工作真棒,但我怎么会把这个位图image.thanks。 – Pramodhini
如果它的有用,然后upvote它..... – Signare