I never had this actual case, but i guess you need to do something with intents:
I hope this helps.
You did not dream that. It can actually exist.
You can do that with a barcode scanner, for instance, a Zebra or a Panasonic Toughbook. It does not just have a camera, but also a barcode scanner.
Choose the hardware button that you want to trigger the scanner and in the settings of your scanner set this hardware button(s) of the scanner to make it trigger the barcodescanner.
Choose a character for use as lineend/returncode, for instance %
Set the datacommunication of the barcode-settings (another app, not ‘settings’) to postfix the scanned barcode with your character
Create a widget that you can place on a page and that triggers a nanoflow upon receiving the character you choose.