Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old October 5th, 2011, 04:26 PM   #1 (permalink)
New Member
 
Join Date: Oct 2011
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Notsure Same Bluetooth Connection for all Activities?

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.

rich2020 is offline  
Reply With Quote
Sponsors
Old October 31st, 2011, 01:06 AM   #2 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

Use a Service

Check the Sample apps for BluetoothChat, it uses a "fake" service, should help you get started at least.
alostpacket is offline  
Reply With Quote
Reply

Bookmarks

Tags
activity, bluetooth, java


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:48 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo