サーバーにイメージがあります。画像の URL は次のようなものです: http://www.mydomain.com/123456uploaded_image.jpg
この画像を ImageView に設定しようとしています。これが私が試したコードです:
try{
String url1 = myeventimagearray[position];
URL ulrn = new URL(url1);
HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
InputStream is = (InputStream) con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
iveventimg.setImageBitmap(bmp);
else
Log.i("Image","Not set");
} catch(Exception e) {
e.printStackTrace();
}
これを試してみると、イメージ ビューが空です。つまり、イメージ ビューが設定されず、logcat に次のシステム エラーが表示されます。
java.lang.ClassCastException: libcore.net.http.FixedLengthInputStream を com.example.eventnotifier.Base64$InputStream にキャストできません
Base46.java は、Base64 表記との間でエンコードおよびデコードするインターネットから見つけたファイルです。
この System.error が発生する理由はわかりますか?
ありがとうございました