[英]How can i receive image from Gmail to my app in Android
我有一個應用程序通過Android上的Gmail中的“預覽圖像”接受圖像
我有Uri:
內容://gmail-ls/messages/my_gmail_id_@_gmail.com/65/attachments/0.1/SIMPLE/false
Astro圖像查看器或圖庫可以很好地顯示圖像
我可以使用URI:content:// media / external / images / media / 79
但我不知道如何使用這個Uri在我的應用程序中顯示圖像。
請幫幫我
抱歉,最后的答案。 我在那里有點尷尬。 但這應該是你想要的更多。 這個確切的代碼可能會或可能不會運行,但從概念上講,這是我發現它應該工作的方式。 如果您有任何問題,請告訴我。
//Get your uri
Uri mAndroidUri = Uri.parse("content://gmail-ls/messages/my_gmail_id_@_gmail.com/65/attachments/0.1/SIMPLE/false");
ImageView iv = new ImageView(context);
try{
//converts android uri to java uri then from that to file
//after converting to file you should be able to manipulate it in anyway you like.
File mFile = new File(new URI(mAndroidUri.toString()));
Bitmap bmp = BitmapFactory.decodeStream(mFile);
if (null != bmp)
iv.setImageBitmap(bmp);
else
System.out.println("The Bitmap is NULL");
}catch(Exception e){}
}
這對我有用:
if (uri.toString().startsWith("content://gmail")) { // special handling for gmail
Bitmap b;
InputStream stream = activity.getContentResolver().openInputStream(uri);
b = BitmapFactory.decodeStream(stream);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.