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

Error: java.lang.NullPointerException in latest 2.0.0 virsion

Open ShridharMe-Kore opened this issue 4 years ago • 4 comments
trafficstars

[Error: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference] share ext error

ShridharMe-Kore avatar Jul 05 '21 08:07 ShridharMe-Kore

I've narrowed down that in the Java code, the Intent is coming through as null. Thus "getAction()" or "getType()" fail. I tried revising the AndroidManifest to make sure the intent if being passed through properly, but that didn't help. Also tried modifying the Java code with the PR above (#42), but that didn't work either.

The issue is in this code block:

@RequiresApi(api = Build.VERSION_CODES.KITKAT)
  @ReactMethod
  public void getFileNames(Promise promise){
    Activity mActivity = getCurrentActivity();
    if(mActivity == null) { return; }
    Intent intent = mActivity.getIntent();
    receiveSharingIntentHelper.sendFileNames(reactContext, intent, promise);
    mActivity.setIntent(null);
  }

Any ideas?

davidsalib avatar Sep 13 '21 07:09 davidsalib

I have the same problem. Any solution?

digitalbore avatar Feb 01 '22 18:02 digitalbore

same

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

Same here, it seems for the initial call there is no intent object, so you can check if it´s not null.

  @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  @ReactMethod
  public void getFileNames(Promise promise){
    Activity mActivity = getCurrentActivity();
    if(mActivity == null) { return; }
    Intent intent = mActivity.getIntent();
    if(intent == null) { return; }
    receiveSharingIntentHelper.sendFileNames(reactContext, intent, promise);
    mActivity.setIntent(null);
  }

jtkDvlp avatar Jan 05 '23 16:01 jtkDvlp