From ee9fba07ac9e51006c70548bdec40575a895830a Mon Sep 17 00:00:00 2001 From: Vomatec Innovations <31130956+vomatec@users.noreply.github.com> Date: Tue, 5 Sep 2017 20:18:21 +0200 Subject: [PATCH] I fixed the app crashing exception for Android after pressing 'back' key multiple times after opening the print window. (#149) --- src/android/Printer.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/android/Printer.java b/src/android/Printer.java index eb6b6dc..0f5f467 100644 --- a/src/android/Printer.java +++ b/src/android/Printer.java @@ -347,14 +347,16 @@ public class Printer extends CordovaPlugin { */ @Override public void onDestroy() { - pm.unsetOnPrintJobStateChangeListener(); + if(pm != null && listener != null && command != null && view != null) { + pm.unsetOnPrintJobStateChangeListener(); - pm = null; - listener = null; - command = null; - view = null; + pm = null; + listener = null; + command = null; + view = null; - super.onDestroy(); + super.onDestroy(); + } } /**