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!
Automatically enable disabled package from appdrawer
-
- Posts: 7
- Joined: Sun Jan 27, 2019 3:41 pm
Re: Automatically enable disabled package from appdrawer
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:
And the variant to enable/disable a single component:
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);
Code: Select all
setComponentEnabledSetting
-
- Posts: 7
- Joined: Sun Jan 27, 2019 3:41 pm
Re: Automatically enable disabled package from appdrawer
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?
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
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.
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
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.