I am developing an application that should add its shortcut to the main screen after installation and delete it after uninstalling the application. The application will be pre-installed on the end-user device, but it must have an option for uninstalling). The task looks very simple, but I encountered many problems that implement it.
What I've done:
- Add a shortcut to the main screen using com.android.launcher.action.INSTALL_SHORTCUT the first time you launch the application or on the device to connect new devices reboot.
- MANUALLY remove the shortcut using com.android.launcher.action.UNINSTALL_SHORTCUT.
That I cannot (and almost refuse):
- Automatically delete the shortcut when the application is uninstalled.
It is not possible to use Intent.ACTION_PACKAGE_REMOVED because the application being deleted does not receive this intention. I performed some tests and found out that the only type of shortcut that can be deleted using the application is the shortcut created in the menu "Add to Home Screen =>" Shortcuts "=" Applications ">" Application Activity ". Shortcuts that are created programmatically or declared in AndroidManifest, remain on the main screen after the application is uninstalled.
There are almost no documents and forum posts on this issue, and I'm a little confused why such a simple operation, which does not contradict the Android security policy, cannot be implemented directly.
Is there any way to ask the OS to remove the corresponding shortcut when uninstalling the application? Can I catch an event that the application is being deleted before it is deleted?
android homescreen android-launcher
Vladimir Dmi
source share