PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 6, 2022

[FIXED] How can i receive image from Gmail to my app in Android

 May 06, 2022     android, gallery, image, uri     No comments   

Issue

I've got an app that accepts images via "Preview images" in Gmail on Android

I have the Uri :

content://gmail-ls/messages/my_gmail_id_@_gmail.com/65/attachments/0.1/SIMPLE/false

The Astro image viewer or Gallery can display the image very well

I can use the URI : content://media/external/images/media/79

but I dont know how to use this Uri to display image in my app.

Help me please


Solution

Sorry about that last answer. I am a bit embarrassed there. But this should be more of what you are looking for. This exact code may or may not run but conceptually this is way I found it should work. Let me know if you have any issues.


//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){}
}



Answered By - Terrance
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing