Alias for mipmap launcher icon

Viewed 229

Is it possible to somehow make alias for mipmap icon? For example we have icon named icon_app but in our lib we use ic_launcher (as it should be). So for drawables you are able to create reference with values/drawables.xml

I tried with following approach:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <item name="ic_launcher" type="mipmap">@mipmap/icon_app</item>
</resources>

but it seems its not working i tried naming it both drawables.xml and mipmaps.xml, it seems it always tries to reference it from drawable instead of mipmap folder?

1 Answers

Further attempts show that the code originally posted works fine when compiled onto device, but is just not recognised by Android Studio.

I was hoping to alias the system default launcher icon, and this seems to work:

<resources>
    <item name="test_alias" type="mipmap">@android:mipmap/sym_def_app_icon</item>
</resources>

...as do these:

<resources>
    <mipmap name="test_alias">@android:mipmap/sym_def_app_icon</mipmap>
    <mipmap name="test_alias2">@mipmap/ic_test</mipmap>
</resources>

...where ic_test is a "normal" mipmap in my res/mipmap resources folder.


To explain the use case in my situation, this above code is in a library project. The test_alias mipmap is declared in the library so that I can use it to put up a Notification.

But the intention is that the developer using the library would be able to override this icon with their own launcher, or other icon of their choosing by adding something like this into their own code, overriding the library definition:

<resources>
    <mipmap name="test_alias">@mipmap/ic_launcher</mipmap>
</resources>
Related