2010-11-20 70 views
0

我有以下代碼:圖像不得到認可

FileOutputStream out = null; 

try { 
out = new FileOutputStream("/sdcard/tmp/i.jpg"); 
b.compress(Bitmap.CompressFormat.JPEG, 90, out); 
Toast.makeText(getApplicationContext(), "Succeded", Toast.LENGTH_LONG).show(); 
} catch (Exception e) { 
Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_LONG).show(); 
} 

Intent share = new Intent(Intent.ACTION_SEND); 

share.setType("image/jpeg");  

share.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/tmp/i.jpg")); 

startActivity(Intent.createChooser(share, "Share image")); 

當它被稱爲這一切工作正常。該文件被保存並彈出選擇器。但一旦你選擇了你所選擇的活動,他們都會彈出一條消息,說我無法添加該圖片。除了GMail,它工作正常。那麼我究竟該怎麼做才能解決這個問題?

+2

如果有什麼的每一個問題被命名爲OMG DUDE !!!( – 2010-11-20 18:51:22

回答

1

我看不到任何代碼可以關閉FileOutputStream。也許這是問題的原因?嘗試在保存圖像後撥打out.close()

UPDATE:

也可嘗試使用完整的圖像路徑,即嘗試做水木清華這樣的:「爲什麼?是不是這方面的工作」

share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/tmp/i.jpg")); 
+0

)謝謝,我一直試圖破解過去10個小時的海峽。 – Bananable 2010-11-20 19:31:02