How to detect shortcut in Home screen

前端 未结 3 518
借酒劲吻你
借酒劲吻你 2020-12-05 05:32

I have an app that allows you to create \"shortcuts\" in Home Screen. But can i detect if the \"shortcuts\" already exist, i didn\'t have to create it again. Thanks.

3条回答
  •  醉话见心
    2020-12-05 06:10

    I was having the same issue. I don't think its possible for you to tell if it's there, but I think what I used will work for you as well.

    Simply uninstall the shortcut before you add it!

    intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
    getApplicationContext().sendBroadcast(intent);
    
    intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    getApplicationContext().sendBroadcast(intent);
    

    Just make sure you add the following to your manifest file.

        
    

提交回复
热议问题