android - Opening a recently written file using Intents -
we downloading file server , writing folder on sdcard. write finishes, perform media scan on folder. when user tries open file viewing, try leverage upon intent mechanism of android , raise intent follows:
intent myintent = new intent(intent.action_view,uri.fromfile(tempfile)); // mime_type either of: image/*, video/*, audio/*, text/* myintent.settype(mime_type); startactivity(intent.createchooser(myintent, "open file using..."));
on emulator, camera application launched intent application crashes npe. , on motorola milestone, getting toast says: "no image show". note photo displayed in media gallery of both emulator , phone scan finishes.
not sure has been missed here; please help.
strangely, changing
intent myintent = new intent(intent.action_view,uri.fromfile(tempfile)); // mime_type either of: image/*, video/*, audio/*, text/* myintent.settype(mime_type);
to
intent myintent = new intent(intent.action_view); // mime_type either of: image/*, video/*, audio/*, text/* myintent.setdataandtype(uri.fromfile(tempfile), mime_type);
worked!
Comments
Post a Comment