android - Intent to view jpeg email attachments? -


i made image viewer opens image using file name. works when click image in file manager using uri, , set default viewer.

however, if email image attachment (i use k9 mail client) , click on image thumb, viewer gets file name "view". makes sense, there's no file in system. of course, can save attachment , see it, don't want this.

so, question is: how can make viewer attachment directly? maybe correct question: email client return when click attachment "link" in email?

edit

this how try open uri in code:

        uri = getintent().getdata();         if (uri != null)             string file = getrealpathfromuri(uri); 

and funcion getrealpathfromuri is:

private string getrealpathfromuri(uri contenturi) {     cursor cursor = getcontentresolver().query(contenturi, null, null, null, null);     if (cursor == null || cursor.getcount() == 0) {         return contenturi.getpath();     } else if (cursor.getcount() == 0) {         return null;     } else {         cursor.movetofirst();         int idx = cursor.getcolumnindex(mediastore.images.imagecolumns.data);         string path = cursor.getstring(idx);         cursor.close();         return path;     } } 

with code, path content://com.fsck.k9.attachmentprovider/34fc2cc9-aa46-45e9-9e3f-2f27f0457249/1‌​/view, wrong of course. correct 1 should /mnt/sdcard/android/data/com.fsck.k9/files/34fc2cc9-aa46-45e9-9e3f-2f27f0457249‌​.db_att/1.

so correct question is: why above getrealpathfromuri() function not return correct filepath?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -