2011-10-07 8 views
10

Kullanıcı bir bildirimi tıkladığında bir şeyin nasıl yapıldığını gösteren birçok örnek gördüm, ancak aslında bir şey olmasını istemiyorum. Eğer kullanıcı bildirimi tıklarsa, bildirimin basit bir şekilde kaybolmasını istiyorum ve kullanıcı hiçbir yere ALMAMIŞTIR.Tıklandığında mutlak hiçbir şey yapmayan bir bildirim nasıl yazılır?

Aşağıdaki kodumda, FLAG_AUTO_CANCEL bildirimi durum çubuğundan temizlerken, kullanıcı benim bildirimi tıklattığında "Etkinliğim" bölümüne yönlendirilir.

Hiçbir şey yapmayan bir bildirimi nasıl oluşturabilirim?

Notification notification = new Notification(R.drawable.success, res.getString(R.string.messages_sent), System.currentTimeMillis()); 

     //Define the expanded message and intent 
     Context context = getApplicationContext(); 
     CharSequence contentTitle = res.getString(R.string.messages_sent_ellipsis); 


     Intent notificationIntent = new Intent(this, MyActivity.class); 
     PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 
     notification.setLatestEventInfo(context, contentTitle, mStrSuccessMessage, contentIntent); 
     notification.flags |= Notification.FLAG_AUTO_CANCEL; 
     //Pass the notification to the notification manager 
     mNotificationManager.notify(1, notification); 
+1

olası kopyası [Kullanıcı tıklattığında bir bildirimi nasıl iptal edebilirim?] (Http://stackoverflow.com/questions/7682009/how-can-i-cancel-a-notification-when-the- kullanıcı tıkladığında-on-o) –

cevap

17

Intent notificationIntent = new Intent(this, MyActivity.class); 

Intent notificationIntent = new Intent(); 

için değiştirme işi yapardı. Eğer bir şey istemezsen, boş bir niyet ver.

İlgili konular