'How can I print in android from any activity

I'm trying to build an app that would print via Bluetooth to a thermal printer.

I've come across a problem: the activity where the printing occurs gets destroyed or finished with the finish() method. Then the app tries to print again sending new information to the printing activity, but can't, because the printer is already bonded with a previous object.

How can I print in Android from any activity I need to print, once the device is bonded to the printer?

I've read about Service but, couldn't get it to work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source