繁体   English   中英

如何在Android中将图像从Gmail接收到我的应用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM