Steve Warner Steve Warner - 5 months ago 60
Android Question

Uri permission is not granted to a path of provider

I have a provider in my app

<provider android:authorities="" android:exported="false" android:name="">
<grant-uri-permission android:pathPrefix="/"/>

And when I call the following intent:

Intent intent = new Intent();
intent.setClassName(getPackageName(), "");

I get exception

Caused by: java.lang.SecurityException: Permission Denial: starting
Intent { dat=content:// flg=0xc3
cmp=com......../com......... (has extras) } from
ProcessRecord{44955bc0 9477:com...../u0a260} (pid=9477,
uid=10260) not exported from uid 10261

What I do wrong? I tried to specify full path to a file or different directory, but it never worked.

Answer Source
intent.setClassName(getPackageName(), "");

Most likely, this is not the actual line of code that is in your app; your real code is specifying some other app. Regardless, this component is not exported, and therefore you cannot access it from your app.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download