0

J'ai configuré l'icône de l'application (Image 1), mais l'icône de notification (Notification envoyée via Firebase) affiche un rectangle gris (Image 2). Quelle est la procédure pour modifier l'image de l'icône de notification (Image 2) via Android Studio 2.3 ou via un script?Q: Modifier l'icône de notification dans Android Studio

Manifest

<?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> 

image 1 image 2

+0

ajouter un code de notification lorsque vous le créez. Besoin de plus d'informations. – kimkevin

Répondre

0

Dans le fichier manifeste. Définir les métadonnées Le code suivant est mon cas.

<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> 
+0

Après avoir inclus la méta-date, l'icône et la couleur ont été modifiées avec succès. – Ever

+0

Pouce vers le haut s'il vous plaît, j'ai besoin de point. –

0

EDIT: Ma réponse est non pertinent: Je ne l'ai pas lu la partie de messagerie Firebase.


utiliser simplement setSmallIcon(int), fourni par NotificationBuilder et son homologue Compat.

Vous pouvez récupérer l'icône de votre dossier resource en transmettant, par ex. R.drawable.my_icon comme paramètre.