String imageurl="http://265xiaoxiao.com/Images/logo.gif";
public Bitmap getBitmap(String imageUrl)
{
Bitmap mBitmap=null;
try
{
//URL
URL url=new URL(imageUrl);
//HttpURLConnection
HttpURLConnection conn=(HttpURLConnection)url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(300000);
if(conn.getResponseCode()==HttpURLConnection.HTTP_OK)
{
InputStream is=conn.getInputStream();
mBitmap=BitmapFactory.decodeStream(new PatchInputStream(is));
}
}
catch(MalformedURLException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
return mBitmap;
}
------解决方案--------------------
<uses-permission android:name="android.permission.INTERNET"/>
在你的manifest文件里面加上这句,应该是没有访问网络的权限,我在我的电脑上可以返回200