Need to force close app and clear its cache

335 views
Skip to first unread message

Kyle Witten

unread,
Oct 11, 2018, 12:18:01 PM10/11/18
to Tasker
I need to write a task that will force close a particular app and clear its cache.

I've found plenty of ways to do it if I have root access, but my phone is not rooted.

Does anyone know how to do this on a phone without Root?

Robert Ryan

unread,
Oct 11, 2018, 1:11:47 PM10/11/18
to tas...@googlegroups.com
Without root, the only way to do this is to use a plug-in, e.g. AutoInput, to simulate screen taps. I use this subroutine. Use Perform Task to call this, setting %par1 to the package of the app to stop. Here is the description of the task:

        Stop App
        
    A1: Send Intent 
        Action: android.settings.APPLICATION_DETAILS_SETTINGS 
        Cat: Default 
        Data: package:%par1 
        Target: Activity 
        
    A2: AutoInput Action 
        Type: Text
        Value: Storage
        Action : Click 
        Timeout (Seconds): 20 
        
    A3: AutoInput UI Query 
        App Package: com.android.settings
        Text: CLEAR CACHE 
        Timeout (Seconds): 20 
        
    A4: Wait 
        MS: 100 
        Seconds: 0 
        Minutes: 0 
        Hours: 0 
        Days: 0 
        
    A5: AutoInput Action 
        Type: Text
        Value: CLEAR CACHE
        Action : Click 
        Timeout (Seconds): 20 
        
    A6: AutoInput Global Action 
        Action: Back 
        Timeout (Seconds): 20 
        
    A7: AutoInput Action 
        Type: Text
        Value: FORCE STOP
        Action : Click 
        Timeout (Seconds): 20 
        
    A8: AutoInput UI Query 
        App Package: com.android.settings
        If you force stop an app, it may cause errors. 
        Timeout (Seconds): 20 
        
    A9: AutoInput Action 
        Type: Text
        Value: FORCE STOP
        Action : Click 
        Timeout (Seconds): 20 
        
    A10: AutoInput Global Action 
        Action: Back 
        Timeout (Seconds): 20 


Philip Schaffer

unread,
Oct 11, 2018, 1:23:29 PM10/11/18
to Tasker
Very nice Robert.  I'm going to save this myself in case I ever need it in the future.

Kyle Witten

unread,
Oct 11, 2018, 1:34:34 PM10/11/18
to Tasker
Thanks!

Unfortunately I don't think this is going to work for me. If I'm reading your script correctly it takes 160 seconds to run start to finish. I am needing something that is near instantaneous.

My problem is that I have an app that will under certain circumstances hijack the screen and force itself to the front, and, unfortunately it is a work program that I can't go without. The developer's recommendation is to restart the phone, but I'm wanting to avoid that if possible because a restart could potentially cause problems with my mileage tracking apps.

A shortcut to the relevant page in settings would work just fine - but for some reason I can't figure out how to create a setting shortcut on the Samsung S9 Plus (something I've done many times on other phones).

Robert Ryan

unread,
Oct 11, 2018, 1:41:10 PM10/11/18
to tas...@googlegroups.com
On October 11, 2018 11:34:39 AM Kyle Witten <ktwi...@gmail.com> wrote:
Unfortunately I don't think this is going to work for me. If I'm reading your script correctly it takes 160 seconds to run start to finish.

Where did you get that idea? If you are looking at the timeouts, those is only used if something goes wrong.

The task takes less than two seconds, start to finish.

Kyle Witten

unread,
Oct 11, 2018, 2:15:24 PM10/11/18
to Tasker
Got you - and, yes, I was counting the timeouts.

It looks like it may just be perfect. 

Thanks!

Kyle Witten

unread,
Oct 11, 2018, 4:19:55 PM10/11/18
to Tasker
Thanks again. Not only did it work perfectly, but using App Factory I compiled it into an app that I can launch from Samsung's Edge menu.

João Dias

unread,
Oct 12, 2018, 7:53:50 AM10/12/18
to tas...@googlegroups.com
Thank you Robert!! :)

Thank you for your contact.

   Join: connect multiple devices (send pushes, remote SMS, notifications) on Android, Windows, Mac, Linux
   Tasker: customize/automate anything on your phone!
   AutoApps: add advanced functionality to Tasker via plugins

     

João Dias


--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Aleksander

unread,
Nov 26, 2018, 11:51:11 PM11/26/18
to Tasker

How can I clear the cache of all programs? without installing third-party programs and without root?
Reply all
Reply to author
Forward
0 new messages