开发者社区 问答 正文

android asynHttp下载PDF文件时报空指针?报错

手机端下载服务端的pdf文件,代码如下:

// PDF文件下载
			String[] allowedContentTypes = new String[] { "application/pdf",
					"image/png", "image/jpeg" };
			HttpUtil.get(url, params, new BinaryHttpResponseHandler(
					allowedContentTypes) {
				@Override
				public void onSuccess(byte[] binaryData) {
					super.onSuccess(binaryData);
					Log.i("-----pdf onSuccess-------", binaryData.toString());
				}

				@Override
				public void onFailure(Throwable error, String content) {
					super.onFailure(error, content);
					Log.i("-----pdf error-------", content);
				}
			});
报错如下:

请问这是什么原因呢?求指教

展开
收起
爱吃鱼的程序员 2020-06-14 20:47:32 743 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    binaryData是空的,调用binaryData.toString()当然会报空指针异常。换了最新得asynHtpp包就好了

    2020-06-14 20:47:50 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论