Use bluetooth connection in two activities

Asked

Viewed 371 times

0

I’m creating a small app with two activities, the first is a screen with only a 'connect' button, after connected to the bluetooth module it would change to the second screen (Second Activity) where would be the command to send by bluetooth.

The question is: How to use the connection made in the first Activity to send data in the second...

I thought about passing the Bluetoothsocket as an extra on Intent, but it was not possible because it does not implement serializable.

  • You want to send what exactly from the first to the second Activity?

  • So, here’s the problem, I’m not sure it’s necessary... but I’ve had the idea to send the Bluetoothsocket or the Inputstream.... My intention is to isolate the connection and the sending of data

  • And my last question: what is the purpose of passing on this information?

  • I didn’t want the other screen I sent the commands to be "polluted" with a button to connect...

  • So you want to remove this button? I don’t understand what your goal is about passing parameters to a second activity. Can you explain only the purpose of this transfer? It seems to me you want to do something simple through a lot of work.

  • That, wanted to make an input screen. A "cover" with the button connect. If the connection established, it would enter the second Activity.

  • I think you should isolate all this logic that deals with Bluetooth for a Service, as it would avoid the coupling with a certain Activity.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.