小编web*_*way的帖子

如何使用 Picasso 共享从服务​​器加载的图像?

我需要帮助。
我已经使用网络服务从服务器获取了一张图片,但我不分享这张图片。

我附上了我的代码,请帮我找出错误。

share.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Bitmap bitmap = viewToBitmap(iv, iv.getWidth(), iv.getHeight());
        Intent shareintent = new Intent(Intent.ACTION_SEND);
        shareintent.setType("image/jpeg");
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
        File file = new File(Environment.getExternalStorageDirectory() + 
                             File.separator + "Imagedemo.jpg");
        try {
            file.createNewFile();
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            fileOutputStream.write(byteArrayOutputStream.toByteArray());
        }
        catch (IOException e) {
            e.printStackTrace();
        }

        shareintent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/Imagedemo.jpg"));

        startActivity(Intent.createChooser(shareintent,"share image"));
    }
}); 
Run Code Online (Sandbox Code Playgroud)
public static Bitmap viewToBitmap(View view, int width, int height){

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas …
Run Code Online (Sandbox Code Playgroud)

android picasso

3
推荐指数
1
解决办法
1844
查看次数

标签 统计

android ×1

picasso ×1