1. Are you ready for the Galaxy S20? Here is everything we know so far!

Difficulties with Bluetooth Socket on Different Activity

Discussion in 'Android Development' started by Alvaro Vargas, Oct 24, 2019.

  1. Alvaro Vargas

    Alvaro Vargas Lurker
    Thread Starter

    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?
     

    Advertisement

    #1 Alvaro Vargas, Oct 24, 2019
    Last edited: Oct 24, 2019
  2. Alvaro Vargas

    Alvaro Vargas Lurker
    Thread Starter

    It seems like there is no standard way to do it.

    So many views though. I bet it is almost 600 views of people looking for an answer to the same question.
     
    #2 Alvaro Vargas, Nov 4, 2019
    Last edited: Nov 18, 2019
Loading...

Share This Page

Loading...