ajith-ab / react-native-receive-sharing-intent

A React Native plugin that enables React Native apps to receive sharing photos, videos, text, urls or any other file types from another app
MIT License
291 stars 105 forks source link

java.lang.NullPointerException on some devices #151

Open ggunti opened 1 year ago

ggunti commented 1 year ago

In my app I allowed to share images (jpeg, png) and pdf files.

Image sharing is working properly. But on some android devices (ex. Huawei mate 10 lite) when I try to share a pdf file, I simply get "java.lang.NullPointerException" in the error callback function. On some another devices it just simply works.

Captură de ecran din 2022-11-30 la 12 23 03

What could cause this error on some android devices? And why only regarding pdf sharing? (as I mentioned, image sharing works always on all devices).

I added these filters to the AndroidManifest.xml file:

        <!-- Add this filter, if you want to support sharing png images into your app-->
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/png" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/png" />
        </intent-filter>
        <!-- Add this filter, if you want to support sharing jpg and jpeg images into your app-->
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/jpeg" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/jpeg" />
        </intent-filter>
        <!-- Add this filter, if you want to support sharing pdf files into your app-->
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/pdf" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/pdf" />
        </intent-filter>

And these permissions:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
"react": "17.0.2",
"react-native": "0.68.2",
"react-native-receive-sharing-intent": "^2.0.0"
fukemy commented 1 year ago

any solution please

GobindaSaha commented 1 year ago

I'm facing the same problem.

Mohammad-DH commented 1 year ago

me too

Mohammad-DH commented 1 year ago

i cant even find the app in the share menu !

esonetec commented 1 year ago

@Mohammad-DH: Try adding the following intent to android/app/main/AndroidManifest.xml:

`

<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
<data android:mimeType="image/*" />
<!-- Any other mime types you want to support -->

`