SORU
27 ŞUBAT 2013, ÇARŞAMBA


Tıkladıktan sonra Kaldır bildirim

Bildirim kullanıcı tıkladıktan sonra kapalı olacağını istiyorum. Herkes bunu söyleyip bayrakları kullanmak gördüm, ama NotificationCompat kullanıyorum çünkü bayrakları hiçbir yerde bulamıyorum.Builder sınıfı ve Bildirim bir sınıf değil. Birisi onu kendine göre bildirim kaldırmak için nasıl bir fikrin var mı?
Bildirim ayarı olduğumda: işte benim kod

NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle("New Question")
            .setContentText(""   QuestionData.getAuthor().getUserName()   ": "   QuestionData.getQuestion()   "");

    Intent openHomePageActivity = new Intent("com.example.ihelp.HOMEPAGEACTIVITY");
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addNextIntent(openHomePageActivity);

    PendingIntent resultPendingIntent =
            stackBuilder.getPendingIntent(
                0,
                PendingIntent.FLAG_UPDATE_CURRENT
            );
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);       

    mNotificationManager.notify(0, mBuilder.build());

CEVAP
27 Mart 2013, ÇARŞAMBA


Çok kolay, sadece bu ara:

mBuilder.setAutoCancel(true);

Eğer gerçekten kullanmak istiyorsanız bu gerçekten gerekli değil ise de,, FLAG_AUTO_CANCEL sadece mNotificationManager.notify aramadan önce bu çağrı:

mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Excel Video Tutorials

    Excel Video

    6 Aralık 2012
  • JamesAtiPhone

    JamesAtiPhon

    16 EYLÜL 2010
  • The Amazing Atheist

    The Amazing

    20 Kasım 2006