This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

invoke a method when app is closed

hi,

I'm developing bluetooth low energy application, using bluetoothgatt, I would like to have a connection going as long as application is running. 

which function can I relay on to be called on application being closed? (I understand onTerminate isn't assured to be called)

I want to invoke the bluetoothGatt.close() function.

Currently I'm not using it and I see that the other side keeps on sending data to the android for about 30 seconds.. leading the next app connection to have invalid old data.. (I'm thinking it is because I'm currently not calling close..)

any help would be greatly appreciated, also maybe there is a place for me to see source code of working apps? (I'm new to android programming) 

  • It's better to ask this kind of question in Android forum, not in Arm platform forum.

    Usually the server app should setup a "heart beat" connection to the client app. Once the periodic heart beat connection is broken, the client/server knows that the connection is closed.

  • The function I want to run in the background, is simply a function that checks whether a notification should arrive and displays it.