Alvaro Vargas
Lurker
Hello Android forums people.
To make it quick, I have been trying to make an app that displays nearby bluetooth devices so I can then connect to one of them and begin interaction, you know, sending simple data, like text. So far, that has been done using one Activity, a bluetooth item adapter, a class to manage the connection and data transmission with different threads, a custom listview with onItemClick events, and some of that other fun stuff, and yes, it works as is.
The thing is, I want to preserve the bluetooth socket and use it in another Activity, which has different buttons to send different kinds of data to the connected device (an electronic device with bluetooth connectivity and a microcontroller....not an arduino).
I have seen so many posts with different suggestions, but nothing really pinpointing in the right direction. "Use threads!, Use Services!, Use the Application class!, Use AsyncTask!". Again, just suggestions, but not a way of explaining how to do it.
I never thought it would be so difficult to pass the active bluetooth socket to another activity. You can certainly pass primitive data types with different methods, but not something like a bluetooth socket; and that is all I really need so I can send data.
So.... any ideas on how I can overcome this?
To make it quick, I have been trying to make an app that displays nearby bluetooth devices so I can then connect to one of them and begin interaction, you know, sending simple data, like text. So far, that has been done using one Activity, a bluetooth item adapter, a class to manage the connection and data transmission with different threads, a custom listview with onItemClick events, and some of that other fun stuff, and yes, it works as is.
The thing is, I want to preserve the bluetooth socket and use it in another Activity, which has different buttons to send different kinds of data to the connected device (an electronic device with bluetooth connectivity and a microcontroller....not an arduino).
I have seen so many posts with different suggestions, but nothing really pinpointing in the right direction. "Use threads!, Use Services!, Use the Application class!, Use AsyncTask!". Again, just suggestions, but not a way of explaining how to do it.
I never thought it would be so difficult to pass the active bluetooth socket to another activity. You can certainly pass primitive data types with different methods, but not something like a bluetooth socket; and that is all I really need so I can send data.
So.... any ideas on how I can overcome this?
Last edited: