diff --git a/android/src/main/java/com/react/SmsModule.java b/android/src/main/java/com/react/SmsModule.java index 7a27616..ad130f1 100644 --- a/android/src/main/java/com/react/SmsModule.java +++ b/android/src/main/java/com/react/SmsModule.java @@ -118,7 +118,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) { @@ -126,7 +129,7 @@ else if (fcontent != null && !fcontent.isEmpty()) } } catch (JSONException e) { errorCallback.invoke(e.getMessage()); - return; + // return; 'return' is unnecessary as the last statement in a 'void' method. } } @@ -185,7 +188,7 @@ public void send(String addresses, String text, final Callback errorCallback, fi successCallback.invoke("OK"); } catch (PendingIntent.CanceledException e) { errorCallback.invoke(e.getMessage()); - return; + // return; 'return' is unnecessary as the last statement in a 'void' method. } } return; @@ -208,7 +211,7 @@ public void delete(Integer id, final Callback errorCallback, final Callback succ return; } catch (Exception e) { errorCallback.invoke(e.getMessage()); - return; + // return; 'return' is unnecessary as the last statement in a 'void' method. } }