Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old October 5th, 2011, 04:26 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Oct 2011
Posts: 1
 
Device(s):
Carrier: Not Provided

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.

Advertisements
rich2020 is offline  
Reply With Quote
sponsored links
Old October 31st, 2011, 01:06 AM   #2 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,920
 
Device(s): GlassXE, MotoX, N5, N4, N7'12, GNex, N1, SGT10.1, Revue, Xoom, Eris, OG Droid
Carrier: TMO

Thanks: 4,603
Thanked 3,579 Times in 1,530 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
Tags
activity, bluetooth, java


Go Back   Android Forums > Android Development > Application Development
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 05:29 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.