Gracefully close an App with Tasker?

1,539 views
Skip to first unread message

Dan

unread,
Nov 7, 2014, 6:52:24 AM11/7/14
to tas...@googlegroups.com
I currently close Apps with Tasker/AutoInput. Either by using the Back button as needed, or if the App has a close or exit menu button, I use that one. 
The issue I have is that I have to bring the App into foreground.

Alternatively, I could use Tasker's "Kill App".
 
In certain cases, killing is not the right thing. For example, my Audiobook reader will stay in the Notification bar active in Pause mode. To actually stop it I have to exit via the menu.
By using "Kill App" there might (?) be a danger to loose data (not sure, though) in other Apps when killed. At least when using "Kill App" in root mode, the killing is pretty "aggressive"..

So my question: Is there a way to gracefully close/exit an App without having it to put to the foreground? 

Similar to sending a SIGTERM to a process in Linux/Unix? SIGTERM (kill -15...) is giving the process to be killed the chance to clean up before exiting. I am not sure how Android Apps are built.. do they act on SIGTERM at all?

Dan

David Bage

unread,
Nov 7, 2014, 7:47:51 AM11/7/14
to tas...@googlegroups.com
I would get a terminal emulator and test SIGTERM within the emulator, I know that I've used a few Linux/Unix terms in my Tasker tasks and they work quite well, the main one I use is "kill -2 $(pidof screenrecord) which obviously forces the native screenrecord command to stop recording, not sure if this is what you're looking for though :)

Dan

unread,
Nov 7, 2014, 8:15:30 AM11/7/14
to tas...@googlegroups.com
Thanks David,
That would have been my next step. But I hoped that there was some kind of hidden feature to Kill App (i.e. giving the SIG type as a parameter).
I now experiment with "Run Shell" or the Locale Execute Plug-In. 
Any hint on the simplest way to find an App's PID without having to ps -ax|grep... /variable split, etc?
Dan

Dan

unread,
Nov 7, 2014, 8:18:32 AM11/7/14
to tas...@googlegroups.com
Oh.. just found the TaskKill Tasker plugin... I'll give that one a try..
Reply all
Reply to author
Forward
0 new messages