Android create shortcuts on the home screen

前端 未结 10 882
忘掉有多难
忘掉有多难 2020-11-22 13:16

What I want to do is:

1) I\'m inside an activity, there are 2 buttons. If I click the first one a shortcut is created in my home screen. The shortcut open an

10条回答
  •  迷失自我
    2020-11-22 13:32

    @Siddiq Abu Bakkar Answer works. But in order to prevent creating shortcut every time app launches use shared Preferences.

    final String PREF_FIRST_START = "AppFirstLaunch";
     SharedPreferences settings = getSharedPreferences(PREF_FIRST_START, 0);
        if(settings.getBoolean("AppFirstLaunch", true)){
    
            // record the fact that the app has been started at least once
            settings.edit().putBoolean("AppFirstLaunch", false).commit();
            ShortcutIcon();
    
        }
    

提交回复
热议问题