How to remove application shortcut from home screen on uninstall automatically?

后端 未结 3 416
一向
一向 2021-01-13 00:18

I\'m developing an application that should add its shortcut to home screen after installation and remove it after the application is being uninstalled. The application will

3条回答
  •  隐瞒了意图╮
    2021-01-13 00:42

    I don't believe you can do this.

    Firstly because you cannot uninstall applications that are pre-installed on the device firmware — they exist on the /system partition which is a read-only filesystem.

    Secondly, as you note, your application receives no notification that it is being uninstalled.

    If users may not want to use your application, won't they just ignore the application icon, much like I do for a couple of pre-installed apps on my phone?


    Edit:
    If you are going to pre-install apps (but not on the firmware as commonsware.com notes), you could pre-install two APKs. One of which has no launcher and consists only of a broadcast receiver which handles the ACTION_PACKAGE_REMOVED event and calls UNINSTALL_SHORTCUT.

    I don't believe there is any explicit permission checks that require a shortcut to be removed by the same app that added it, but you could get around that anyway by using a sharedUserId for both APKs.

提交回复
热议问题