David Illichmann
David Illichmann

Reputation: 39

Titanium appcelerator: FileUriExposedException - How to use Content Provider?

I try to open a local pdf but it won't open because of this exception: android.os.FileUriExposedException: file:///storage/emulated/0/appid/1438-938X_2015_07/0.pdf exposed beyond app through Intent.getData()

I think I need to use a content provider, but how can I get the content:// path in appcelerator?

Upvotes: 0

Views: 282

Answers (2)

Raef Akehurst
Raef Akehurst

Reputation: 613

There was a fix in Ti SDK 6.3.0 that fixed this.

Upvotes: 0

David Illichmann
David Illichmann

Reputation: 39

Today I was able to fix my issue.I didn't have to use a content provider. I was using this code to create an Intent:

            Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
            action: Ti.Android.ACTION_VIEW,
            type: 'application/pdf',
            data: pdfPath
        }));

No I am using this code:

var intent = Ti.Android.createIntent({
            action : Ti.Android.ACTION_VIEW,
            type : "application/pdf",
            data: pdfPath
        }); 


        var open = Ti.Android.createIntentChooser(intent, L('open_intent'));
        Ti.Android.currentActivity.startActivity(open);

I hope this helps anyone with a similar problem!

Upvotes: 1

Related Questions