我正在使用Picasso为我的应用下载图像.
我遇到的情况是我需要Bitmap在加载到第一个之前访问第一个ImageView.Downloader.Response该类的存在似乎表明这是可能的,但我找不到任何使用示例.我不想写一堆更多的代码来异步处理这个特殊情况,如果它可以与Picasso一起使用的话.
谁能告诉我怎么做?
我有一个关于从网站加载图像的问题.我使用的代码是:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Bitmap bit=null;
try {
bit = BitmapFactory.decodeStream((InputStream)new URL("http://www.mac-wallpapers.com/bulkupload/wallpapers/Apple%20Wallpapers/apple-black-logo-wallpaper.jpg").getContent());
} catch (Exception e) {}
Bitmap sc = Bitmap.createScaledBitmap(bit,width,height,true);
canvas.drawBitmap(sc,0,0,null);
Run Code Online (Sandbox Code Playgroud)
但它总是返回一个空指针异常,程序崩溃了.该URL有效,似乎适用于其他所有人.我正在使用2.3.1.
我遇到此问题,将应用程序中的图像共享到Gmail会将图像的路径放在"收件人"字段中.
这是我正在使用的代码:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Beam Dental Insurance Card");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // temp permission for receiving app to read this file
shareIntent.setDataAndType(insuranceCardImageUri, getActivity().getContentResolver().getType(insuranceCardImageUri));
shareIntent.putExtra(Intent.EXTRA_STREAM, insuranceCardImageUri);
startActivity(Intent.createChooser(shareIntent, "Share Insurance Card"));
Run Code Online (Sandbox Code Playgroud)
而这就是我得到的.
To:字段将填充图像路径,并从前面删除"content:".我已经尝试设置EXTRA_EMAIL意图,但这没有帮助.