Java android应用程序开发-用户创建的快捷方式,用户定义的名称和图标在应用程序更新时更改

Java android应用程序开发-用户创建的快捷方式,用户定义的名称和图标在应用程序更新时更改,java,android,shortcut,Java,Android,Shortcut,基本上我们有两个发射器活动。MainActivity使用用户选择的自定义图标和名称创建快捷方式,我们将SecondActivity链接到快捷方式 由于快捷方式图标和名称由用户选择,因此没有“真实”默认图标 但是,每当我们在PlayStore中加载应用程序更新时,用户创建的快捷方式的图标和名称都会被默认设置覆盖(应用程序图标和名称) 默认情况下,如果未定义某个活动,则该活动将从应用程序继承图标和名称,但我们无法定义它,因为它总是由用户创建或选择的 我们如何避免在PlayStore上更新应用程序时覆

基本上我们有两个发射器活动。MainActivity使用用户选择的自定义图标和名称创建快捷方式,我们将SecondActivity链接到快捷方式

由于快捷方式图标和名称由用户选择,因此没有“真实”默认图标

但是,每当我们在PlayStore中加载应用程序更新时,用户创建的快捷方式的图标和名称都会被默认设置覆盖(应用程序图标和名称)

默认情况下,如果未定义某个活动,则该活动将从应用程序继承图标和名称,但我们无法定义它,因为它总是由用户创建或选择的

我们如何避免在PlayStore上更新应用程序时覆盖图标和名称

来自ANDROID清单的示例

<application
           android:icon="@drawable/ic_launcher"
           android:label="@string/app_name">
       <activity
               android:name=".MainActivity"
               android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
       <activity
               android:name=".SecondActivity"
               android:theme="@android:style/Theme.NoDisplay"
               android:excludeFromRecents="true"
               android:launchMode="singleInstance">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
</application>
Intent shortcutIntent = new Intent(getApplicationContext(), SecondActivity.class);
shortcutIntent.setAction(Intent.ACTION_VIEW);
shortcutIntent.putExtra("Something", "Blah");

Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

// name is created by the user
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aShortcut.getName()); //getName returns    a String

// icon is selected by the user
BitmapDrawable icon = (BitmapDrawable) aShortcut.getIcon(); // getIcon returns a   drawable
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON,icon.getBitmap());

addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
this.sendBroadcast(addIntent);