2017-01-11 3 views
0

Hallo, ich arbeite an der Push-Benachrichtigung im Android, es funktioniert ordnungsgemäß, aber das Problem ist, dass das separate Benachrichtigungssymbol in der Statusleiste für jede neue Benachrichtigung für E-Mail angezeigt wird. Ich möchte nur das einzelne Icon für die verschiedenen Mails anzeigen, bitte suggeriere mir Lösungen. Ich werde meinen Code unten posten. Vielen Dank im Voraus.....!Benachrichtigungssymbol wird mehrfach angezeigt

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

jemand richtig jede Lösung –

+0

Benachrichtigungsanzeige haben aber das Symbol in der Statusleiste zeigt an, wie oft –

Antwort

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

finden // DIESE FÜR DIE SINGLE LOGO IN DER ANMELDUNG kommentierte Abschnitt in der Antwort –

Verwandte Themen