From 19ccf91e97494403effc06461a037ab82fa4b28e Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 9 Sep 2017 12:50:47 +0800 Subject: [PATCH] add null check --- .idea/modules.xml | 3 --- app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index cf4f13d..a822a05 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,12 +2,9 @@ - - - \ No newline at end of file diff --git a/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java b/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java index 93f5cba..9719e9d 100644 --- a/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java +++ b/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java @@ -312,7 +312,7 @@ public class PrinterBle { } private void sendData(byte[] data) { - if (data == null || data.length < 1 || data.length > 20) return; + if (data == null || data.length < 1 || data.length > 20 || printerCharacteristic == null) return; boolean setVal = printerCharacteristic.setValue(data); boolean sendVal = mBtGatt.writeCharacteristic(printerCharacteristic);