diff --git a/android/src/main/java/com/react/SmsModule.java b/android/src/main/java/com/react/SmsModule.java index 19031cf..4051c81 100644 --- a/android/src/main/java/com/react/SmsModule.java +++ b/android/src/main/java/com/react/SmsModule.java @@ -121,7 +121,10 @@ else if (fcontent != null && !fcontent.isEmpty()) c++; } } - cursor.close(); + // I faced a NPE here, plus it's a good practice to have a null check. + if (cursor != null) { + cursor.close(); + } try { successCallback.invoke(c, jsons.toString()); } catch (Exception e) { @@ -129,7 +132,6 @@ else if (fcontent != null && !fcontent.isEmpty()) } } catch (JSONException e) { errorCallback.invoke(e.getMessage()); - return; } } @@ -188,7 +190,6 @@ public void send(String addresses, String text, final Callback errorCallback, fi successCallback.invoke("OK"); } catch (PendingIntent.CanceledException e) { errorCallback.invoke(e.getMessage()); - return; } } return; @@ -211,7 +212,6 @@ public void delete(Integer id, final Callback errorCallback, final Callback succ return; } catch (Exception e) { errorCallback.invoke(e.getMessage()); - return; } }