0

I have bind an activity to a remote service through aidl interface. Various other activities are also bound to it. After some point of time, calls are getting blocked. When I open that particular activity it starts a handlerthread and it is calling some remote methods through aidl interface. But they are blocked so thread is also getting blocked. Inside onDestroy() method, I am trying to do handlerthread.quit(), but thread is not stopping. So every time I am starting that activity threads are started but not getting stopped on destroying activity.

My question is how can I stop the handlerthread which is in blocked state?

Gambler
  • 31
  • 4
  • Your aidl interface needs to have 'oneway' nonblocking methods calls that return straight away - in your constructor for your 'oneway' method call define a 'callback' to your handler. – Mark Feb 24 '16 at 18:20
  • did you tried thread.interrupt() ? – king Feb 24 '16 at 18:20
  • @user3549047 i tried interrupt. But thread was not stopped. – Gambler Feb 25 '16 at 06:07
  • It seems it got blocked in 'onTransact' waiting for the remote binder thread to respond. – Gambler Feb 25 '16 at 06:15

1 Answers1

0

your aidl interfaces might be bidirectional. try making them oneway which will make them non-blocking.

Also, if your requirement is not to make them onway, check this link there it explains how to stop a handler thread.

srv_sud
  • 647
  • 1
  • 9
  • 26
  • I tried this. mBTHandler.removeCallbacksAndMessages(null); mBTHandler = null; BTWorkerThread.quit(); if(BTWorkerThread.isAlive()) BTWorkerThread.interrupt(); BTWorkerThread = null; But it didnot work. – Gambler Feb 25 '16 at 06:05