2012-04-13 10 views
0

nicht löse ich das Problem haben, wenn der Benutzer drücken Sie die Mitteilung Aktivität offen ist, aber Benachrichtigung kann nicht in der Nähe mir meinen Code werden helfenKönnte die Benachrichtigungen in android

ist

NotificationManager mNotificationManager = (NotificationManager) getSystemService (Context .NOTIFICATION_SERVICE);

int icon = R.drawable.ic_launcher; 
    CharSequence tickerText = "Good Morning"; 
    long time = System.currentTimeMillis(); 

    Notification notification = new Notification(icon, tickerText, time); 

    Context context = getApplicationContext(); 
    CharSequence contentTitle = "Title"; 
    CharSequence contentText = "Text"; 
    Intent notificationIntent = new Intent(this, NotificationManagerDemoActivity.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,0); 
    notification.flags = Notification.FLAG_AUTO_CANCEL; 
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
    mNotificationManager.notify(1,notification); 

Antwort

2

versuchen, es wie this..hope wird es funktionieren .. notification.flags | = Notification.FLAG_AUTO_CANCEL;

+0

Danke Es funktioniert Sav Achrya –

+0

Abstimmung für Ihre Antwort. Groß. Ich habe das auch gemacht. –

0

Setzen Sie Auto Cancel auf True, während Sie Notification wie folgt erstellen.

notificationBuilder.setAutoCancel(true);