interrupt

Interrupting/cancelling threads

SDK Version: 
M3

threadWhen you run a background operation using a Thread, or AsyncTask in most of the times it is needed to be able to interrupt it.
In lot of cases, when the user starts a sceen in our application, a thread is started in the background, to load its content. Hoever if the user leaves the screen before its loading is complete, the loading process should be interrupted. Even if the loading prosess can not be interrupted immediately, or it would be too mutch troube, it shold detect that the display of the result is no longer needed.

So how do you stop a thread exactly? You can see in the documentation that Thread class has a stop() method. This method offered an "easy" way to interrupt threads in older android versions, by killing the thread. It is deprecated now, do not use it, it may left things in inconstent state, among other problems, so this was an unelegant way.

Interrupting a call

SDK Version: 
M3

end callAs far as I know there is no public API for interrupting/ending a call. You can detect calls and the states of calls, maybe even prevent an outgoing call, but there is no API for ending an ongoing call.
This must be a security issue, but I also met the need of this feature, and only was able to do some workaround: turning on airplane mode interrupts all wireless connections including phone calls.

Syndicate content