My user has the possibility to choose to change the application icon and application name, for that I've used an activity-alias
, which is working great.
For example:
- Default Icon with application name as "Application name"
- Alternative Icon with application name as "Alternative Application name"
However when I send a notification to the user, if they chose the alternative icon/application name, the notification title contains the default application. How can I change ?
Here is my notificationBuilder
:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "default")
.setSmallIcon(isAlternativeLaunched ? R.drawable.ic_alternative : R.drawable.ic_default)
.setContentTitle("This is my title")
.setContentText("This is my content")
.setSubText("This is my text")
.setColor(ContextCompat.getColor(context, R.color.colorPrimary));
PS: I've checked and the title of my application is correctly set when using alternativeName, only the notification has the old title.
EDIT: Looking at the doc https://developer.android.com/guide/topics/ui/notifiers/notifications#Templates it is said:
App name: This is provided by the system
What I don't understand is, why is it not changing the app name ?
My activity-alias
look like this:
<activity-alias
android:name="my.package.name.DefaultActivity"
android:enabled="true"
android:icon="@mipmap/ic_launcher_default"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round_default"
android:targetActivity="my.package.name.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
<activity-alias
android:name="my.package.name.AlternativeActivity"
android:enabled="false"
android:label="@string/app_name_alternative"
android:icon="@mipmap/ic_launcher_alternative"
android:roundIcon="@mipmap/ic_launcher_alternative_round"
android:targetActivity="my.package.name.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>