react-native-receive-sharing-intent icon indicating copy to clipboard operation
react-native-receive-sharing-intent copied to clipboard

java.lang.NullPointerException on some devices

Open ggunti opened this issue 2 years ago • 5 comments

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"

ggunti avatar Oct 20 '22 08:10 ggunti

any solution please

fukemy avatar Nov 18 '22 03:11 fukemy

I'm facing the same problem.

GobindaSaha avatar Dec 14 '22 09:12 GobindaSaha

me too

Mohammad-DH avatar Dec 26 '22 17:12 Mohammad-DH

i cant even find the app in the share menu !

Mohammad-DH avatar Dec 26 '22 17:12 Mohammad-DH

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

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

esonetec avatar Dec 30 '22 10:12 esonetec