tl; dr Вы не можете изменить его, потому что значок вашего приложения зарегистрирован в Манифесте Android, который поставляется вместе с ним.
Из документации :
Значки и метки
Ряд элементов манифеста имеют значок и меткуатрибуты для отображения маленького значка и текстовой метки, соответственно, для пользователей для соответствующего компонента приложения.
Это означает, что ваше приложение всегда будет иметь один и тот же значок, поскольку манифест не может быть изменен во время выполнения.Поэтому я предполагаю, что приложение, на которое вы ссылаетесь, является системным приложением с системными привилегиями.
Единственные значки, которые вы можете изменить, - это ярлыки, которые ваше приложение создает с помощью этого разрешения:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
Чтобы создать ярлык, проверьте этот ответ: https://stackoverflow.com/a/40446734/1574250
Чтобы изменить фон при нажатии на значок вашего приложения, вот пример (в этом примере я изменяю только цвет фона, когдаприложение открывается):
Класс:
public class YourActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set you app icon
setColorWallpaper();
// Finish the activity
finish();
}
/**
* Sets the color wallpaper to the color value in the Clipboard, or to a random color.
*/
private void setColorWallpaper() {
// Try to get the color parameter from the clipboard
Integer colorParam = null;
try {
colorParam = ColorClipboardParameter.getColor(getApplication());
} catch (Exception ignored) {
// An unexpected exception while trying to get the color code from the clipboard
// can crash the app at startup. Ignore any exceptions, we will generate a random
// color anyway.
}
// If there is no valid color value in the clipboard, generate a random color
final int color = (colorParam != null) ? colorParam : GoodRandomColor.nextColor();
try {
// Set the color wallpaper
ColorWallpaper.setColorWallpaper(this, color);
// Success: copy the color code to the clipboard
Utils.copyText(this, Utils.colorToHex(color));
// Go to the home screen
Utils.goHome(this);
} catch (IOException e) {
// Write the stack trace to System.err and copy the reason of the failure to clipboard
e.printStackTrace();
Utils.copyText(this, e.toString());
}
}
}
Манифест:
<application
android:fullBackupContent="true"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:installLocation="auto"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".YourActivity"
android:excludeFromRecents="true"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Проверьте этот проект для болееинформация: https://github.com/appgramming/LoneColor-Android