简体   繁体   中英

Android Passing BluetoothSocket to the next Activity

After connecting to the bluetooth, I need the child to send data out through that socket. But how do I get the socket over to the childActivity?

Not sure if it is the best design, but what I did here and it worked on my simple application was to have the bluetooth connection (the socket) as a "global variable", a variable of my main application (the class which extends the Application class).

In that way all my activities can get it and set it.

For doubts on how to set/get a global variable on such way, refer to Android global variable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM