Android: open file in byte array representation with Intents
I'm a litte bit desperate to open a file with intent so that android can decide which application should handle this file. My Problem is that i have only the file as an Base64 representation which i decode to an byte Array
Now i want to send an intent and open that file. I try to do save it in the internal storage and open the file with the uri given by getFilesDir(). Here is my Code
FileOutputStream fos = openFileOutput(filename, Context.MODE_WORLD_READABLE );
fos.write((byte[])result);
fos.close();
uri = Uri.fromFile(new File(getFilesDir(), filename));
Intent myIntent = new Intent(Intent.ACTION_VIEW);
myIntent.setData(uri);
startActivity(myIntent);
Unfortunatly this doesn't work. All i got is an ActivityNotFoundException (even 开发者_高级运维if i try to open a *.jpg)
Thanks for any input!
Android does not try to guess MIME types based on file extensions. You need to expressly set the MIME type in the Intent
.
精彩评论