如何将应用程序图标设置为通知抽屉中的通知图标

时间:2015-12-11 14:26:26

标签: android android-studio notifications android-notifications android-notification-bar

如图所示......
我收到了通知图标(左侧是红色) 但我需要显示应用程序图标,如黑色箭头所示

enter image description here

Private Sub FindN(StrSearchQuery As String)
    Set SearchRange = Range("versement adherent!F2:Y21")
    FindN = StrSearchQuery

    Function FindAll(SearchRange As Range, LookFor As String)
        Dim FoundCell As Range

        For Each area In SearchRange.Areas
            With area
                If .cell(.cell.Count).Row > MaxRow Then
                    MaxRow = .cell(.cell.Count).Column
                End If
            End With

        Next area
        Set lastcell = SearchRange.Worksheet.Cells(MaxRow, MaxCol)
        Do Until True
            Set FoundCell = SearchRange.Find(N)
            If FoundCell = False Then
        Exit Do

        If FoundCell = True Then
            For Each FoundCell In Worksheet("versement adherent").Range(FoundCell)
                Range("versement adherent !Foundcell").Value = Pay
                Range(FoundCell).Value = X
            Exit Do

        End If
    End Function

    Set FoundCell = FindAll

    If FoundCell = True Then
        For Each FoundCell In Worksheet("versement adherent").Range(FoundCell)
        Range("versement adherent !Foundcell").Value = Pay
    End If

3 个答案:

答案 0 :(得分:48)

在通知构建器中尝试此代码:

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
                        R.mipmap.ic_launcher))
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

android.app.NotificationManager notificationManager =
                (android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());

设置大图标可以解决问题。如果你有任何进一步的信息,请在下面评论

答案 1 :(得分:46)

我知道在这里回答有点迟,而且已经回答了问题,但是我来到这里寻找使用firebase通知的简单修复。像我这样访问的人可以通过推荐和简单的firebase通知方式来做解决方案,这只是在清单中添加元数据。

Reference

<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
<meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/ic_stat_ic_notification" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. -->
<meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/colorAccent" />

答案 2 :(得分:0)

在构建通知时设置此参数

setLargeIcon(BitmapFactory.decodeResource(context.getResources(),R.mipmap.ic_launcher))