• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Same Bluetooth Connection for all Activities?

rich2020

Lurker
Hi all,

New to Android, so this may seem obvious.

Here's what I have: A class called BT_Comm
BT_Comm creates a bluetooth connection and allows me to send data with it via a method called sendData(int xxx, int yyy);

Now, I use this BT_Comm in my main activity -the first one.

Say I have 10 Activities, how could I access that same BT_Comm in other Activities?

Eg:

-------------------------------------------------------
Activity 1 (main)
Code:
BT_Comm bt = new BT_Comm();

pubic void someMethod()
{
bt.sendData(xxx, yyy);
}
-------------------------------------------------------

Activity 2
Code:
private void someOtherMethod()
{
bt.sendData(xxx, yyy);
}

-------------------------------------------------------

Activity 3
Code:
private void someOtherMethod()
{
bt.sendData(xxx, yyy);
}

-------------------------------------------------------

Does anyone know how I might do this?

Thanks,

Rich.
 
Use a Service :)

Check the Sample apps for BluetoothChat, it uses a "fake" service, should help you get started at least.
 
Back
Top Bottom