Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Keep gathering Bluetooth Low Energy data in background on Android

Discussion in 'Android' started by Tapgames, Jan 16, 2017.

  1. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    Hi All,

    I have made an app called Deskbike for Android and iOS. I made this app in Unity3D because there will be a small game included. This app connects to a Bluetooth Low Energy device called a Deskbike this is a small hometrainer for under your desk at work ;)

    Now my problem is that users complain when they have the app open and receive a phone call or when another app is opened the app stops receiving cadences information from the bike and the user will lose all there data in between.

    I searched the forums for stopping unity to go into sleep when in the background by altering the UnityPlayerActivity pause function this is not doing anything. Maybe it's me, I added a Debug.Log in the update function and see it printing in the console and when I send the app in to the background it stops printing so I assume it stops running. This is of course tested from in the app on the phone not in the editor.

    Now this is a fitness app and I need to get data from the bike when the app is send to the background and if the user stops biking and the bluetooth connection disconnects after a minute of idle the app will save the progress closes it self to stop the app running forever and save the batteries on the phone ;)

    What are my options here?

    Thanks, Roy
     
  2. Tapgames

    Tapgames

    Joined:
    Dec 1, 2009
    Posts:
    242
    No one?
     
  3. AgusB

    AgusB

    Joined:
    Jun 20, 2013
    Posts:
    65
unityunity