1

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!

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.