2017-01-11 15 views
0

こんにちは私はアンドロイドでプッシュ通知に取り組んでいますが、正しく動作していますが、ステータスバーにメールの新しい通知ごとに別の通知アイコンが表示されています。私はちょうど複数のメールのための単一のアイコンを表示したい私に解決策を提案してください。私は下に私のコードを掲載します。前もって感謝します.....!通知アイコンが複数回表示されています

int icon = R.drawable.app_icon; 
    long time = System.currentTimeMillis(); 

    NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 
    Intent notificationIntent; 

    if(event.equals("1")) 
    { 
    i++; 
    try{ 

    String msg; 
    if(!full_name.equals("") || !full_name.equals("null")) 
    { 
    msg="New ticket created by "+full_name+""; 
    } 
    else 
    { 
    msg="New ticket created by client ("+i+")"; 
    } 

    notificationIntent = new Intent(context,Ticket_Tabs.class); 
    notificationIntent.putExtra("filter_id","&vis_filter_id=1");   
    notificationIntent.putExtra("title",(String)context.getString(R.string.inbox)); 
    notificationIntent.putExtra("client_id",client_id); 
    notificationIntent.putExtra("dept_id",department_id); 
    notificationIntent.putExtra("set_queue","no"); 
    notificationIntent.putExtra("Ticket_hash",hash); 
    notificationIntent.putExtra("Ticket_id",ticket_id); 


    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_NEW_TASK); 

    String x_id = UUID.randomUUID().toString(); 
    notificationIntent.putExtra("x_id", x_id); 
    notificationIntent.setAction(x_id); 



    PendingIntent pending_intent =PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); 


    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) 
    .setWhen(time) 
    .setContentTitle((String)context.getString(R.string.app_name)) 
    .setContentText(msg) 
    .setSmallIcon(icon) 
    .setAutoCancel(true)  
    .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_VIBRATE| Notification.DEFAULT_SOUND) 
    .setContentIntent(pending_intent); 

    Notification notification=notificationBuilder.build(); 
    notificationManager.notify(i, notification); 


    } 
    catch(Exception e) 
    { 
    Log.d("Exception in Notification : ",e.toString()); 
    } 
    } 
+0

誰もが適切にすべてのソリューション –

+0

通知表示を持っていますが、ステータスバーにアイコンが回数を示し –

答えて

0
 int icon = R.drawable.app_icon; 
     long time = System.currentTimeMillis(); 

     NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 
     Intent notificationIntent; 

     if(event.equals("1")) 
     { 
     i++; 
     try{ 

     String msg; 
     if(!full_name.equals("") || !full_name.equals("null")) 
     { 
     msg="New ticket created by "+full_name+""; 
     } 
     else 
     { 
     msg="New ticket created by client ("+i+")"; 
     } 

     notificationIntent = new Intent(context,Ticket_Tabs.class); 
     notificationIntent.putExtra("filter_id","&vis_filter_id=1");   
     notificationIntent.putExtra("title",(String)context.getString(R.string.inbox)); 
     notificationIntent.putExtra("client_id",client_id); 
     notificationIntent.putExtra("dept_id",department_id); 
     notificationIntent.putExtra("set_queue","no"); 
     notificationIntent.putExtra("Ticket_hash",hash); 
     notificationIntent.putExtra("Ticket_id",ticket_id); 


     notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_NEW_TASK); 

     String x_id = UUID.randomUUID().toString(); 
     notificationIntent.putExtra("x_id", x_id); 
     notificationIntent.setAction(x_id); 



     PendingIntent pending_intent =PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); 


     NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) 
     .setWhen(time) 
     .setContentTitle((String)context.getString(R.string.app_name)) 
     .setContentText(msg) 
     .setSmallIcon(icon) 
     .setAutoCancel(true)  
     .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_VIBRATE| Notification.DEFAULT_SOUND) 
     .setContentIntent(pending_intent); 

              if(i!=0)//THIS ONE FOR THE SINGLE LOGO IN THE NOTIFICATION 
        { 
         notificationBuilder.setPriority(NotificationCompat.PRIORITY_MIN); 
        } 

     Notification notification=notificationBuilder.build(); 
     notificationManager.notify(i, notification); 


     } 
     catch(Exception e) 
     { 
     Log.d("Exception in Notification : ",e.toString()); 
     } 
     } 
+0

//通知にSINGLE LOGO FOR THIS ONEを探すの答えにセクションをコメント –

関連する問題