3

画像をリクエストしているのですが、SkImageDecoder::Factory returned nullとなります。
statuscodeは200でした。
URLはhttps://outlook.office365.com/owa/service.svc/s/GetFileAttachment?id=HOGEHOGE.です。

try {
    HttpGet httpGet = new HttpGet(URL);
    CookieManager cookie = CookieManager.getInstance();
    String cookiestr = cookie.getCookie(URL);
    httpGet.setHeader("Cookie", cookiestr);
    DefaultHttpClient client = new DefaultHttpClient();

    HttpResponse httpResponse = client.execute(httpGet);
    int statusCode = httpResponse.getStatusLine().getStatusCode();
    Log.d("","statusCode:"+statusCode);
    HttpEntity entity = httpResponse.getEntity();
    //String response = EntityUtils.toString(entity);
    //Log.d("","response:"+response);
    BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity);
    final InputStream in = bufferedEntity.getContent();

    Bitmap bitm = BitmapFactory.decodeStream(in); 
    entity.consumeContent();
    client.getConnectionManager().shutdown();
} catch (MalformedURLException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
5
  • ちなみにpdfです。jpgは特に問題ありませんでした。
    – fumiki
    2015年2月27日 7:10
  • PDFには対応していないようです。github.com/google/skia/blob/…
    – h2so5
    2015年2月27日 7:22
  • h2so5さんありがとうございます。何かPDFをダウンロードしてImageViewへ表示させる方法はありますか?
    – fumiki
    2015年2月27日 8:06
  • 2
    API Level 21 からですが PdfRenderer が使えます。 2015年2月27日 9:15
  • Kyosuke Kamedaさん ありがとうございます。確認してみます。
    – fumiki
    2015年2月27日 9:47

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。