EMDK Barcode Scanning lifecycle events for Xamarin.Android

// Expert user has replied.
M Mike Bedford 3 years 1 month ago
12 1 0

As we can see from the EMDK documentation and sample application on Github, we need to "wire up" the Android lifecycle events (ie: onResume, onStart, etc...) to the EMDK so we properly initialize the EMDK, barcode scanner and then release it when we are done. As we know, the lifecycle events can be overridden on each activity. The sample app provided assumes you only have one activity with your application. However, how should the EMDK work when you have multiple activities? For example, I have and EMDK instance in Activity 1 and wire all of the lifecycle events up so I have a barcode scanner. Then, my app wants to close Activity 1 and move to Activity 2. Do I release the barcode scanner in activity 1 and then fire up a new one in activity 2 or do I find some way to hold on the the barcode scanner globally and keep it while the app is running so I can move between activities without releasing it and then grabbing it again every time I transisition?

What is the best practice here?

Thanks!

Mike

CONTACT
Can’t find what you’re looking for?