2014-02-13 39 views
3

我有一个图像浏览及分享按钮活动分享位图, 图像从DB如何保存和android中

检索

我想保存在第一图像,然后分享它

每一个事情是怎么回事罚款,图像保存在内部存储器,它会分享,但当其他应用程序运行(如WhatsApp或消息)它说,文件不支持

我已推动其他图像ddms手动,然后共享工作没有任何问题!吴

我认为这个问题是从节约位图,甚至我检查从DDMS保存的位图,它是看起来不错

有我的代码:

保存

try { 
     FileOutputStream out = new FileOutputStream(new File(getFilesDir(), "temp.png")); 
     imageview.setImageBitmap(b1); 
     b1.compress(Bitmap.CompressFormat.PNG, 100, out); 
     out.flush(); 
     out.close(); 
     } 
     catch (Exception e) {} 

分享方法

private void initShareIntent(String type,String _text) 
    { 
     Intent shareIntent = new Intent(); 
     shareIntent.setAction(Intent.ACTION_SEND); 
     shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(getFilesDir(), "temp.png"))); 
     shareIntent.setType("image/PNG"); 
     shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
     startActivity(Intent.createChooser(shareIntent, "send")); 
    } 
+0

你是如何获得的位图? –

回答

0

编辑本

shareIntent.setType("image/*"); 

对此

shareIntent.setType("image/png"); 

,我认为它应该工作。请让我知道这对你有没有用!!

[EDIT1]更改为PNG(而不是PNG)因为我认为案件在这里很重要。笑

[EDIT2]多个图像试试这个(由Google提供:P)

ArrayList<Uri> imageUris = new ArrayList<Uri>(); 
imageUris.add(imageUri1); // Add your image URIs here 
imageUris.add(imageUri2); 

Intent shareIntent = new Intent(); 
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); 
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); 
shareIntent.setType("image/*"); 
startActivity(Intent.createChooser(shareIntent, "Share images to..")); 
+0

我以前试过这个:D它不工作 –

+0

我认为这种情况在MIME类型 – SMR

+0

没有问题不从这里 我已经检查过每一件事情,因为我伤心它是保存位图,但它不是共享,但如果我改变位图手动它的工作:| –