From 6f820691f2c1158ced03c1514714435b269d65a9 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Fri, 27 Jan 2023 11:38:39 +0100 Subject: [PATCH] Added more logs for the Status Receiver lifecycle --- .../datawedgeprofileintents/DWStatusScanner.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/datawedgeprofileintentswrapper/src/main/java/com/zebra/datawedgeprofileintents/DWStatusScanner.java b/datawedgeprofileintentswrapper/src/main/java/com/zebra/datawedgeprofileintents/DWStatusScanner.java index 126ea72..8a67f9c 100644 --- a/datawedgeprofileintentswrapper/src/main/java/com/zebra/datawedgeprofileintents/DWStatusScanner.java +++ b/datawedgeprofileintentswrapper/src/main/java/com/zebra/datawedgeprofileintents/DWStatusScanner.java @@ -28,6 +28,7 @@ public DWStatusScanner(Context aContext, DWStatusScannerSettings settings) { public void start() { + Log.d(TAG, "Start Status Scanner Receiver"); /* Register notification broadcast receiver */ @@ -41,6 +42,7 @@ public void start() public void stop() { + Log.d(TAG, "Stop Status Scanner Receiver"); unRegisterNotificationReceiver(); unRegisterForScannerStatus(mStatusSettings); } @@ -72,6 +74,7 @@ public void onReceive(Context context, Intent intent) { protected void registerForScannerStatus(DWStatusScannerSettings settings) { + Log.d(TAG, "Scanner Receiver: registerForScannerStatus"); Bundle b = new Bundle(); b.putString(DataWedgeConstants.EXTRA_KEY_APPLICATION_NAME, settings.mPackageName); b.putString(DataWedgeConstants.EXTRA_KEY_NOTIFICATION_TYPE, DataWedgeConstants.NOTIFICATION_TYPE_SCANNER_STATUS); @@ -83,6 +86,7 @@ protected void registerForScannerStatus(DWStatusScannerSettings settings) protected void unRegisterForScannerStatus(DWStatusScannerSettings settings) { + Log.d(TAG, "Scanner Receiver: unRegisterForScannerStatus"); Bundle b = new Bundle(); b.putString(DataWedgeConstants.EXTRA_KEY_APPLICATION_NAME, settings.mPackageName); b.putString(DataWedgeConstants.EXTRA_KEY_NOTIFICATION_TYPE, DataWedgeConstants.NOTIFICATION_TYPE_SCANNER_STATUS); @@ -114,7 +118,13 @@ void unRegisterNotificationReceiver() { try { mContext.unregisterReceiver(mStatusBroadcastReceiver); //Android method } - catch(Exception e) + catch(IllegalArgumentException e) + { + Log.d(TAG, "registerNotificationReceiver(): Trying to unregister a receiver that has not been previously released.."); + Log.d(TAG, "registerNotificationReceiver(): Status receiver should be started before trying to stop it."); + //e.printStackTrace(); + } + catch (Exception e) { e.printStackTrace(); }