首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >问:在Android中更改通知图标

问:在Android中更改通知图标
EN

Stack Overflow用户
提问于 2017-10-19 02:14:26
回答 2查看 4.8K关注 0票数 2

我配置了应用程序图标(图1),但是通知图标(通过Firebase发送的通知)显示了一个灰色的矩形(图2)。通过AndroidStudio2.3或通过脚本更改通知图标图像(图2)的过程是什么?

流形

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.studioshow.studioshow">
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity android:name=".MainActivity">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />


        </intent-filter>
    </activity>
</application>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-19 04:34:23

在清单文件中。设置元数据。下面的代码是我的案例。

代码语言:javascript
运行
复制
   <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"  >
        <activity
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        <service
            android:name=".MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_launcher" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/whitechoke" />

    </application>
票数 8
EN

Stack Overflow用户

发布于 2017-10-19 07:43:01

编辑:--我的答案与此无关:我没有读过关于Firebase消息传递部分的内容。

只需使用setSmallIcon(int),由NotificationBuilder及其Compat对应方提供。

您可以通过传递从resource文件夹中检索图标,例如R.drawable.my_icon作为参数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46821916

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档