I'm developing an app bluetooth to communicate with a device. I have to send to that device a certain packet and that device respond to me in notify mode after a certain time. All works well, but I have to check if the response arrive to me in 3 seconds, and if it doesn't arrive in time, I have to send another command without waiting anymore to previous packet.
In what way Can I implement a timer in Android ?
I have thought to : 1- start timer when I send a packet 2- stop timer when the response arrive to me or if the msg was sended more 3 seconds ago the timer triggers function and it enable to resend other msg
I think to do it with handler and postdelay.
What do you think ? are there a better ways to implement this ?
Maybe a TimerTask ?