Skip to content

Commit

Permalink
Added more logs for the Status Receiver lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrudu committed Jan 27, 2023
1 parent 3d72d87 commit 6f82069
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public DWStatusScanner(Context aContext, DWStatusScannerSettings settings) {

public void start()
{
Log.d(TAG, "Start Status Scanner Receiver");
/*
Register notification broadcast receiver
*/
Expand All @@ -41,6 +42,7 @@ public void start()

public void stop()
{
Log.d(TAG, "Stop Status Scanner Receiver");
unRegisterNotificationReceiver();
unRegisterForScannerStatus(mStatusSettings);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 6f82069

Please sign in to comment.