c# – 状态栏通知xamarin native android

c# – 状态栏通知xamarin native android,第1张

概述我是Xamarin的新手,到目前为止这是我的代码.它不会给出任何错误或显示通知. NotificationCompat.Builder builder = new NotificationCompat.Builder(Activity) .SetAutoCancel(true) .SetContentIntent(resultPendingInten 我是Xamarin的新手,到目前为止这是我的代码.它不会给出任何错误或显示通知.

NotificationCompat.Builder builder = new NotificationCompat.Builder(Activity)            .SetautoCancel(true)            .SetContentIntent(resultPendingIntent)            .SetContentTitle("My Notifications")            .SetContentText(" Work dammit -_-");            notificationmanager notificationmanager = (notificationmanager)Activity.GetSystemService(AndroID.Content.Context.NotificationService);            notificationmanager.Notify(buttonClickNotification,builder.Build());
解决方法 我找到了解决问题的方法.

I got my solution from here

voID CreateNotification(string Title,string desc)        {            //Create notification            var notificationmanager = GetSystemService(Context.NotificationService) as                  notificationmanager;            //Create an intent to show ui            var uiIntent = new Intent(this,typeof(MainActivity));            //Create the notification            var notification = new Notification(Resource.Drawable.Icon,Title);            //var notification = new Notification(AndroID.Resource.Drawable.SymActionEmail,Title);            //auto cancel will remove the notification once the user touches it            notification.Flags = NotificationFlags.autoCancel;            //Set the notification info            //we use the pending intent,passing our ui intent over which will get called            //when the notification is tapped.            notification.SetLatestEventInfo(this,Title,desc,PendingIntent.GetActivity(this,uiIntent,0));            //Show the notification            notificationmanager.Notify(1,notification);        }
总结

以上是内存溢出为你收集整理的c# – 状态栏通知xamarin native android全部内容,希望文章能够帮你解决c# – 状态栏通知xamarin native android所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1233151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存