nativescript-community / nativescript-community/ui-document-picker

Android 11 : pdf document throw com.android.providers.media.documents throw NullpointerException

Open
#7 18 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
11
Forks
8
PR merge metrics
No merged PRs in 30d

Description

When i select a pdf document, the content uri is

content://com.android.providers.media.documents/document/document%3A30

Logcat logs :

D/[FilePath plugin]:: File - Authority: com.android.providers.media.documents, Fragment: null, Port: -1, Query: null, Scheme: content, Host: com.android.providers.media.documents, Segments: [document, document:30]

FilePath.getPath is looking for a media document

       // MediaProvider
        else if (isMediaDocument(uri)) {

The docId is document:30, type is "document"

But doesn't handle "document"

           Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

=> contenUri is Null

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with FilePath.getPath and the MediaProvider branch shown in the issue, using the Android 11 content URI and logcat output as the reproduction. Trace how the document type is handled and verify that selecting a PDF no longer produces a null content URI or NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.