Uygulamamda kullanıcıya bildirim göstermem gerekiyor. Aşağıdaki kod snippet'i, Android cihaz başlık çubuğundaki simge ve içerik başlığını göstererek harika çalıştı.Durum Çubuğunda Bildirim Metnini Görüntüleme - Android
var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
var uiIntent = new Intent(this, typeof(MainActivity));
var notification = new Notification(Resource.Drawable.AppIcon, title);
notification.Flags = NotificationFlags.AutoCancel;
notification.SetLatestEventInfo(this, title, desc, PendingIntent.GetActivity(this, 0, uiIntent, 0));
notificationManager.Notify(1, notification);
Uygulamayı dağıtmak için paket oluşturmaya çalıştığımda, şu hatayı alıyorum:
Ben de kullanıyor olmalıdır bu kod parçacığını buldum ve statü simgesini gösterirAndroid.App.Notification.SetLatestEventInfo(Android.Content.Context, string, string, Android.App.PendingIntent)' is obsolete: 'deprecated'
Intent resultIntent = new Intent(this, typeof(MainActivity));
PendingIntent pi = PendingIntent.GetActivity(this, 0, resultIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(Forms.Context)
.SetContentIntent(pi)
.SetAutoCancel(true)
.SetContentTitle(title)
.SetSmallIcon(Resource.Drawable.AppIcon)
.SetContentText(desc); //This is the icon to display
NotificationManager nm = GetSystemService(Context.NotificationService) as NotificationManager;
nm.Notify(_TipOfTheDayNotificationId, builder.Build());
ne android cihaz durum çubuğunda içerik başlığı görüntülemek için yeni kod parçacığının oluşturmam gerekiyor değil içerik başlığa göre bar?
bunu yapamaz mı? – njzk2
Hayır, öyle değil. –
Mümkün Bildirimlerin nasıl uygulanması (http://stackoverflow.com/questions/16852270/how-to-implement-the-deprecated-methods-of-notification) – njzk2