我試圖從url加載圖像到我的android ImageView。但它沒有給我的網址形象。但是當我打電話另一個樣本網址加載在ImageView的URL圖像將不會設置爲ImageView Android
我的URL這給空
https://192.168.100.15/HeyVoteWeb/Home/GetImage/d9cbd32c-47fc-4644-ab97-1f525c96e9ed/100000102
此示例網址爲我的作品
https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png
這是我的代碼我正致力於
public class GetImage extends Activity{
ImageView postpic1;
Bitmap b;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.all_posts);
postpic1 = (ImageView) findViewById(R.id.postpic1);
information info = new information();
info.execute("");
}
public class information extends AsyncTask<String, String, String>
{
@Override
protected String doInBackground(String... arg0) {
try
{
URL url = new URL("https://localhost/HeyVoteWeb/Home/GetImage/d9cbd32c-47fc-4644-ab97-1f525c96e9ed/100000102");
InputStream is = new BufferedInputStream(url.openStream());
b = BitmapFactory.decodeStream(is);
} catch(Exception e){}
return null;
}
@Override
protected void onPostExecute(String result) {
postpic1.setImageBitmap(b);
}
}
}
這是URL '的https:// 192.168.100.15/HeyVoteWeb /主頁/的getImage/d9cbd32c-47fc-4644-ab97-1f525c96e9ed/100000102' – Naz141
是的,我看到了。這是對本地HTTPS網絡服務器的調用,那麼你有一個運行?如果沒有,這個URL永遠不會給你一張圖片。這將調用您正在運行此操作的計算機/設備,而不是**網絡上的隨機圖像(僅供說明)。 – LilaQ
yes在您的瀏覽器中運行該網址 – Naz141