STMicroelectronics / BlueSTSDK_Android

Bluetooth low energy Sensors Technology Software Development Kit (Android version)
https://www.st.com/en/embedded-software/bluest-sdk.html
BSD 3-Clause "New" or "Revised" License
92 stars 46 forks source link

Passing nodes between activities #10

Closed jcarellanov closed 7 years ago

jcarellanov commented 7 years ago

The app I'm working on will have to pass nodes between different activites. I was going to go with something like this, for Node n:

Intent j = new Intent(ScanActivity.this, MainHub.class); j.putExtra("node",n); startActivity(j);

But I realize now Node is not serializable since it has private Handler mBleThread;

I was wondering if you had any suggestions for retrieving the node object in MainHub?

GiovanniVisentiniST commented 7 years ago

Hi,

you can pass the node tag (it is a string) and then get the node back using the Manager class.

if you need to keep the node connected, you can use the NodeConnectionService and the ActivityWithNode or the NodeContainer interface.

you can see an example here: DemoActivitiy passing the node to DebugConsole

jcarellanov commented 7 years ago

Thank you, that was it