Android Serial Communication

Source: Internet
Author: User
Tags root access

Today in the whole project, the need to use serial communications on the Internet to read a lot of people's posts just a little bit of a clue.

First, the serial code is the use of Google's own API, the Java code in the Java/android_serialport_api directory, if you want to change the registration need to use JNI to regenerate so file, here I directly use the package name to simplify the work.

The structure of the Androidstudio is as follows:

So file:

Add Dependencies in Gradle:

So you can

Although SerialPort has an error, he can do it without him.

This allows you to use the serial communication

Using a serial port requires a phone or simulator with a corresponding port and then requires root access. Here I use the simulator to test the serial port.

Test serial port requires two software, COM debugging assistant, virtual serial port driver

First open the virtual serial port driver to add two serial ports

Then find the path to the SDK is generally C:\Users\ your computer \appdata\local\android\sdk\tools

Set the emulator to the serial port on the PC.

This allows you to open the emulator to see

Indicates that your Android virtual machine is already a COM1

Then turn on the COM debugging assistant, so that the configuration device can COM1 and COM2 serial communication directly

Code Download Content Https://codeload.github.com/jzt-Tesla/GoogleSerialPort/zip/master

Android Serial Communication

Related Article

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.