2011-04-15 38 views
0

我有不同的通知,每個通知都有與它們相關的不同捆綁/活動。我的問題是,一旦點擊它們就不會消失。儘管它們並未處於正在進行的通知之下,並且「清除」將其清除。貝婁是我的代碼。任何想法將不勝感激。 :)Android通知不會消失(即使使用Auto_Cancel)

private void showNotification(Bundle b){ 
    CharSequence myText = b.getString("notifStr"); 

    Notification notification = new Notification(R.drawable.stat_sample, myText,System.currentTimeMillis()); 

    Intent i = new Intent(myContext, NewPlace.class); 
    i.setAction(Intent.ACTION_VIEW + Integer.toString(b.getInt("id"))); 
    i.putExtras(b); 

    PendingIntent contentIntent = PendingIntent.getActivity(myContext, 0, i, 0); 

    notification.defaults |= Notification.FLAG_AUTO_CANCEL; 

    notification.setLatestEventInfo(myContext, myText,myText, contentIntent); 

    notifMan.notify(b.getInt("id"), notification); 
} 

回答

1

你應該嘗試

notification.flags |= Notification.FLAG_AUTO_CANCEL; 
2

嘗試改變:

notification.defaults |= Notification.FLAG_AUTO_CANCEL; 

notification.flags |= Notification.FLAG_AUTO_CANCEL; 

通知文件(旗)

公衆詮釋默認

從以下版本開始:API級別1指定應從 默認值中取出哪些 值。要設置,或者從 DEFAULT_SOUND,DEFAULT_VIBRATE, DEFAULT_LIGHTS。對於所有缺省的 值,請使用DEFAULT_ALL。

+0

這應該工作。 – azharb 2011-04-15 17:51:34

相關問題