views:

125

answers:

1

Hi guys,

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!

A: 

Android does not try to guess MIME types based on file extensions. You need to expressly set the MIME type in the Intent.

CommonsWare