Display-Meldung Text in der Status Bar - Android
In meiner Anwendung brauche ich um Benachrichtigung an den Benutzer. Der folgende Codeausschnitt funktioniert großartig auf dem display das Symbol und den Inhalt der Titel auf dem Android-Gerät Titelleiste.
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);
Als ich versuchte, erstellen Sie das Paket für die Bereitstellung der Anwendung, bekomme ich die folgende Fehlermeldung:
Android.App.- Benachrichtigung.SetLatestEventInfo(Android.Inhalt.Kontext,
string, string, Android.App.PendingIntent)' ist obsolet: 'veraltet'
So fand ich dieses code-snippet, das ich mit sollte, und es zeigt das Symbol in der Statuszeile nicht die Inhalte, Titel
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());
Was muss ich in das neue code-snippet für die Anzeige des Inhalts-Titel auf dem android-Gerät status-bar?
- nicht setcontenttitle tun?
- Nein, tut es nicht.
- möglich, Duplikat der Wie die Umsetzung der deprecated Methoden der Benachrichtigung
- (andere Sprache, aber die gleiche api, so dass mögliche Duplikate?)
Du musst angemeldet sein, um einen Kommentar abzugeben.
Muss ich hinzufügen
.setTicker()
zu der zweiten code-snippet um text-display in der Android-Gerät status-barFolgenden code funktionierte für mich. Nur ein paar Korrekturen in der zweiten snippet.