Android Question Return to previous app

barx

Well-Known Member
Licensed User
Longtime User
I fear this will be a limit of Android itself, not B4A.

I have created a small app to open the ZXing Barcode scanner app from the notification bar. All was working well, but today I actually put the app into real use and noticed something that I had assumed would work my way.

The idea of the app is to reduce the barcode scanner / code input process from:
Close the app your in > launch barcode scanner > scan barcode > close barcode scanner > re-launch app > paste code.

To (from an open app):
Open notification bar and tap ZXTrigger (barcode scanner loads) > scan barcode (barcode scanner auto closes with code in clipboard) > paste code.

Everything works right up to the end. Once the barcode scanner auto closes, the previous app is no longer in the background. I was hoping it would just pause and once the scanner closes, the previous app would resume. Does everyone follow?

So is there anyway to get the previous app in code. Obviously it can be loaded by long pressing the home button and picking it out, but it would be nice to get rid of this step.

Thanks for looking.

p.s. this is the app if anyone wishes to take a look ;)
https://play.google.com/store/apps/details?id=barxdroid.ZXTrigger
 

qsrtech

Active Member
Licensed User
Longtime User
I don't think the previous app is "closed", it's just further down the chain cause you're calling the scanner "activity". I do use icefairy's scan lib in another project. I like the fact we don't need to install the real scanner app. Perhaps we can get icefairy's lib updated to better suit us?
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Perhaps we can
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I implemented treehousefrogs code and it was so close it is unreal. If the barcode was scanned it indeed returned to the right app. but if the back button was pressed, I.e. scan cancelled it always returned to launcher. no matter what number task I chose. and got the failed to launch app toast. so bloody close.
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
Man idk why you're wasting your time with that when I gave you code that works 100% lol (at least you're getting some more experience) Did you try turning on the light before calling scanner in my app? All you need is to download icefairy's lib code and add some window size code (and maybe add a light property) and recompile it and share it :p
 
Upvote 0

chrjak

Active Member
Licensed User
Longtime User
hi barx
Maybe you can use a service to scan if the started app is started and if you finish that app the service will show your activity again...
Regards
 
Upvote 0

treehousefrog

Member
Licensed User
Longtime User
I implemented treehousefrogs code and it was so close it is unreal. If the barcode was scanned it indeed returned to the right app. but if the back button was pressed, I.e. scan cancelled it always returned to launcher. no matter what number task I chose. and got the failed to launch app toast. so bloody close.

Glad it *almost* worked... another option is to replace running tasks with recent tasks. That could be more effective? Orrr you could even save the currently running tasks to a string when you launch your app, then return to that package name when they hit back. That way if something weird is happening while your app is running it won't impact the end result. I can't see any way that one could fail! Good luck!
 
Upvote 0
Top