SORU
30 Temmuz 2009, PERŞEMBE


Android hizmetinden bir bildirim gönderme

Bir hizmet olarak çalışan var, ve bir bildirim göndermek ister. Çok kötü, bildirim nesne bir bağlam, bir Faaliyet, bir hizmet gibi değil gerektirir.

Bunu geçmek için herhangi bir yol biliyor musunuz ? Çirkin görünüyor her bildirim bu bir Etkinlik oluşturmak için çalıştı, ve herhangi bir manzarası olmayan bir Faaliyet başlatmak için bir yol bulamıyorum.

CEVAP
30 Temmuz 2009, PERŞEMBE


Her ikisi de Activity Service aslında sadece ** 6 içinde Service this kullanabilirsiniz 3* Context *.

NotificationManager notificationManager =
    (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(/* your notification */);
PendingIntent pendingIntent = /* your intent */;
notification.setLatestEventInfo(this, /* your content */, pendingIntent);
notificationManager.notify(/* id */, notification);

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Amazon Web Services

    Amazon Web S

    8 NİSAN 2009
  • LearnCode.academy

    LearnCode.ac

    20 Aralık 2012
  • RickardRick

    RickardRick

    9 Mart 2007