java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser

1

my code is this: Manifest:  

    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.providers.FileProvider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
    </provider>
</application>

Method to send a photo:

private void dispatchTakePictureIntent(String name) {
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
            File photoFile;
            photoFile = createImageFile(name);
            if (photoFile != null) {
                Uri photoURI = FileProvider.getUriForFile(getApplication().getApplicationContext(),
                        "com.example.pc_intel.photo.provider",
                        photoFile);
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(takePictureIntent, TAKE_PICTURE);
            } else {
                Log.wtf("photoFile", "photoFile null");
            }
        } else {
            Log.wtf("TakePicture", "resolve acivity null");
        }
    }

XML where the path is

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="imagenesFotoA"/>
</paths>
    
asked by heber israel jimenez ordaz 18.02.2018 в 15:23
source

1 answer

0

The package name of your application is:

 "com.example.pc_intel.photo.provider"

therefore the permission that you should assign to your Provider is:

android:authorities="com.example.pc_intel.photo.provider"

instead of:

android:authorities="${applicationId}.providers.FileProvider"
    
answered by 19.02.2018 в 21:46