棋子 · 2020年02月24日

invoke a method when app is closed

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)

1 个回答 得票排序 · 时间排序
极术小姐姐 · 2020年02月24日

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.

你的回答
关注数
1
收藏数
0
浏览数
2049
极术小姐姐
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息