-6

In My App, I have given all permissions like storage, contact etc to app (Given run time permission for marshmallow and above version), but still app shows black screen for some mobile phone.

Permission Denial: opening provider

android.support.v4.content.FileProvider from ProcessRecord{bd58bf1 15489:com.google.android.apps.pdfviewer/u0a213} (pid=15489, uid=10213)

That is not exported from uid 10227.

//Code

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Uri photoURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider",
pdfFile);
        Intent objIntent = new Intent(Intent.ACTION_VIEW);
        List<ResolveInfo> resolvedIntentActivities = context.getPackageManager().queryIntentActivities(objIntent,
PackageManager.MATCH_DEFAULT_ONLY);
        for (ResolveInfo resolvedIntentInfo : resolvedIntentActivities) {
            String packageName = resolvedIntentInfo.activityInfo.packageName;
            context.grantUriPermission(packageName, photoURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION |
Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
        objIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        objIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        objIntent.setDataAndType(photoURI, "application/pdf");
        context.startActivity(objIntent);
    }else{
        Uri path = Uri.fromFile(pdfFile);
        Intent objIntent = new Intent(Intent.ACTION_VIEW);
        objIntent.setDataAndType(path, "application/pdf");
        objIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(objIntent);
    }` 

[Screen] Image

pankaj
  • 21
  • 8
  • 1
    You haven't shown any code, just an error and a blank screen. – David Makogon Jul 06 '17 at 12:23
  • 1
    You appear to be trying to start a third-party PDF viewer, using a `Uri` from `FileProvider`. Given that, you appear to have failed to add `FLAG_GRANT_READ_URI_PERMISSION` to the `ACTION_VIEW` `Intent`, and so that PDF viewer has no rights to access your content. But, as David points out, this is guesswork -- please provide a [mcve] demonstrating your problem. – CommonsWare Jul 06 '17 at 12:26
  • Code added, Please let me know the wrong thing in code – pankaj Jul 06 '17 at 12:27

1 Answers1

0

Hi actually there might be some issue with accessing the FILE URI as it doesnt have the write read uri permission while raising the intent.

check the following thread.. Android - file provider - permission denial hope you will get some idea.

Also post the code here to understand more.

PranavKAndro
  • 921
  • 7
  • 9
  • 1
    I have given objIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); objIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); – pankaj Jul 06 '17 at 12:34