Page 1 of 1

Automatically enable disabled package from appdrawer

Posted: Fri May 24, 2019 4:19 pm
by Wern-YuenTan
I'd like to create a script that checks if a package is disabled, and if it is use a shell command to enable it, before launching the activity itself

This script can then be added to all items in the app drawer to allow automatic launching of disabled apps

Combine this with Tasker's latest app changed context and one can create a "greenify" or "icebox" feature in the main app drawer

I can write the script to get the intent and package of the item but am struggling with the package enable command. Can script gurus @F43nd1r or @TrianguloY help? Thanks!

Re: Automatically enable disabled package from appdrawer

Posted: Sun May 26, 2019 5:46 am
by Pierrot
Keep in mind that disabled apps or components will disappear from the app drawer, so to make it work I either need to modify the app drawer to display disabled apps (this is possible) or apps need to be manually added to a desktop before to be disabled.

To enable the whole app you can use something like:

Code: Select all

PackageManager pm=context.getPackageManager();
pm.setApplicationEnabledSetting(package_name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
And the variant to enable/disable a single component:

Code: Select all

setComponentEnabledSetting

Re: Automatically enable disabled package from appdrawer

Posted: Mon May 27, 2019 4:22 am
by Wern-YuenTan
Thanks Pierre. I just realized that the official LL app drawer does not allow for adding events/actions to either all items or even specific items. One can create a container that mimics app drawer functionality to achieve this, but is there a better workaround?

I also tried the script you provided and replaced "package_name" with the package name variable, as well as the hard coded package name, but both did not work. Threw up an error in the first line. Is it because of how I am defining context (or not), or do I need an import action upfront?

Re: Automatically enable disabled package from appdrawer

Posted: Sat Jun 01, 2019 6:21 am
by Pierrot
The context is the one you can get through Lightning.getActiveScreen().getContext() (for instance).
In fact it is possible to set custom actions on app drawer items (through scripting!) but I would discourage this as it can break the app drawer behavior.

Re: Automatically enable disabled package from appdrawer

Posted: Fri Sep 27, 2019 8:54 pm
by eruben
Can you please explain more detailed how can I create a shortcut on desktop for a disabled app to enable it before launch and disable after closing. If it is possible.