Search code examples
androidbluetoothbluetooth-lowenergyrx-java2rxandroidble

android - Keep bluetooth connection between activities?


let's say i have 2 activities called Activity A and Activity B

i display list of devices on Activity A that users can connect to. when users clicked one of the devices, it will connected to selected bluetooth device and exchange some data first to verify credentials (i.e. login). i have done this part.

when the data is correct i want to move to Activity B where all the main menu is there but i want to keep that connection made before in Activity A so that i don't need to disconnect and reconnect the connection again.

how to do that ? i'm new about this, please help me..

i use this library for the connection : https://github.com/Polidea/RxAndroidBle

thanks before :)


Solution

  • In principle, I would move all Bluetooth code to a Service. Then you would not be tied to any specific activity.