add null check

This commit is contained in:
Jay 2017-09-09 12:50:47 +08:00
parent 8a081b144a
commit 19ccf91e97
2 changed files with 1 additions and 4 deletions

View File

@ -2,12 +2,9 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/BTDemo.iml" filepath="$PROJECT_DIR$/BTDemo.iml" />
<module fileurl="file://D:\Project\ble-android-demo\BTDemo.iml" filepath="D:\Project\ble-android-demo\BTDemo.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://D:\Project\ble-android-demo\app\app.iml" filepath="D:\Project\ble-android-demo\app\app.iml" />
<module fileurl="file://$PROJECT_DIR$/ble-android-demo.iml" filepath="$PROJECT_DIR$/ble-android-demo.iml" />
<module fileurl="file://D:\Project\ble-android-demo\ble-android-demo.iml" filepath="D:\Project\ble-android-demo\ble-android-demo.iml" />
</modules>
</component>
</project>

View File

@ -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);