=============== Problem description ====================
RT: basic question: can a serial receiving Program defined in an activity still receive serial data after the activity is switched to another activity?
My program has two activities, which have verified receiving and sending data in the started activity.
After the second activity is performed, an error occurs when the receiving thread of the serial port returns the first activity from the second activity. After debugging, the serial port is initialized again.
(1) What should I do if I don't want the serial port to be repeatedly initialized?
(2) In the second activity, can the serial port receive data? Because there are no devices for verification, you can only talk about it.
============= Solution 1 ======================
Write the serial port receiver to the background service.
============= Solution 2 ======================
Generally, service is used. However, you can also change the activity startup mode so that the serial port is not created repeatedly.
Basic Question: Can a serial receiving Program defined in an activity still receive serial data if the activity is switched to another activity?