Basic Question: Can a serial receiving Program defined in an activity still receive serial data if the activity is switched to another activity?

Source: Internet
Author: User

=============== 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.

Problem:
(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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.