Same Bluetooth Connection for all Activities?


Last Updated: 2011-10-31 06:06:38
  1. rich2020

    rich2020 New Member

    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 (Text):
    1.  
    2. BT_Comm bt = new BT_Comm();
    3.  
    4. pubic void someMethod()
    5. {
    6. bt.sendData(xxx, yyy);
    7. }
    -------------------------------------------------------

    Activity 2
    Code (Text):
    1.  
    2. private void someOtherMethod()
    3. {
    4. bt.sendData(xxx, yyy);
    5. }
    -------------------------------------------------------

    Activity 3
    Code (Text):
    1.  
    2. private void someOtherMethod()
    3. {
    4. bt.sendData(xxx, yyy);
    5. }
    -------------------------------------------------------

    Does anyone know how I might do this?

    Thanks,

    Rich.

    Advertisement
  2. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Use a Service :)

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

Share This Page