更改android中的通知默认图标? [英] change notification default icon in android?
问题描述
我正在使用 onesignal 并尝试更改默认通知铃铛图标";在应用程序中
I'm using onesignal and trying to change the default notification "bell icon" in the app
所以在从 Android Asset Studio并将其命名为 ic_stat_onesignal_default
并将其添加到 /android/app/src/main/res/
文件夹中,然后我卸载应用程序并重建它,并将其添加到负载通知API"
so after generating my icon from Android Asset Studio
and name it to ic_stat_onesignal_default
and add it into /android/app/src/main/res/
folders, after that I uninstall the app and rebuild it,
and add it to payload notification "API"
small_icon: 'ic_stat_onesignal_default'
但是,我仍然使用默认(铃铛)作为通知图标:(
But still, I got the default one (Bell) as a notification icon :(
有什么我忘记的步骤吗?
is there any step I forget?
如果您想知道,这是我的 AndroidManifest.xml 文件
here's my AndroidManifest.xml file if you wondering
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.salonyUser">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data android:name="com.onesignal.NotificationAccentColor.DEFAULT" android:value="0F0F0F" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
编辑
添加后AndroidManifest.xml
After added AndroidManifest.xml
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_onesignal_default" /> // I choose mipmap-xxxhdpi icon size for test. :)
我只是想测试 firebase 元数据是否有效,实际上它有效,我得到了我想要的图标!!有没有人解释一下!
I just was wanted to test if firebase meta-data will work or not and Actually it's work and I got the icon I want!! have anybody explanation to this!
推荐答案
在 NotificationCompat.Builder 中设置图标,使用 .setSmallIcon() 作为较小的图标和 .setLargeIcon() 用于大图标.
Set icon in the NotificationCompat.Builder using .setSmallIcon() for smaller icon and .setLargeIcon() for large icon.
这篇关于更改android中的通知默认图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!