Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

ANT+ pairing over two activities (Android)

Rank

Total Posts: 2

Joined 2015-02-08

PM

Okei, so I'm making an training application where the pairing part is in one activity and the workout part where I show all the data is in another activity. How can i hold the connection up from one activity to another? I've tried but when i don't close the connection i get a leaked ServiceConnection error.      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

This is more of a generic Android development question than related to ANT. You need to understand how Android services work, especially the difference between bound and started services: http://developer.android.com/guide/components/services.html
Your activities would bind to the service whenever they need to control the connection, with the service being started whenever there is a connection you want to keep open.

A foreground service while a connection is open is your safest option for not having the connection closed in the background as Android tries to free resources.

Is the intention that the user needs to go through the pairing process once, and in the future they go straight to the workout and it connects itself? In this case why do you need to keep the connection open, as the workout activity would need to open a connection itself most of the time anyway.

Another alternative is to keep it all in one activity, with different layouts.

-R      

Signature

blackramlabs.com