使用 MonoDroid C# 显示状态栏通知

发布于 2024-10-14 13:47:53 字数 68 浏览 3 评论 0原文

如何使用 C# 通过 MonoDroid 显示状态栏通知?

有人能给我举个例子吗?

谢谢。

How can I show a status bar notification with MonoDroid using C#?

Can someone give me an example?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

十雾 2024-10-21 13:47:53

您想要使用 Android.App.Notification 和 < a href="http://docs.monodroid.net/index.aspx?link=T:Android.App.NotificationManager" rel="noreferrer">Android.App.NotificationManager,例如来自 LocalService.ShowNotification()

// within some Android.Content.Context subclass (Activity, Service, etc.)
void ShowNotification ()
{
    IEnumerable<char> text = GetText (Resource.String.local_service_started);
    var notification = new Notification (Resource.Drawable.stat_sample, 
            text, 
            System.Environment.TickCount);
    PendingIntent contentIntent = PendingIntent.GetActivity (this, 0, 
            new Intent (this, typeof (LocalServiceActivities.Controller)), 
            0);
    notification.SetLatestEventInfo (this, 
            GetText ([email protected]_service_label), 
            text, 
            contentIntent);
    var nm = (NotificationManager) GetSystemService (NotificationService);
    nm.Notify (Resource.String.local_service_started, notification);
}

You want to use Android.App.Notification and Android.App.NotificationManager, for example from LocalService.ShowNotification():

// within some Android.Content.Context subclass (Activity, Service, etc.)
void ShowNotification ()
{
    IEnumerable<char> text = GetText (Resource.String.local_service_started);
    var notification = new Notification (Resource.Drawable.stat_sample, 
            text, 
            System.Environment.TickCount);
    PendingIntent contentIntent = PendingIntent.GetActivity (this, 0, 
            new Intent (this, typeof (LocalServiceActivities.Controller)), 
            0);
    notification.SetLatestEventInfo (this, 
            GetText ([email protected]_service_label), 
            text, 
            contentIntent);
    var nm = (NotificationManager) GetSystemService (NotificationService);
    nm.Notify (Resource.String.local_service_started, notification);
}
抱着落日 2024-10-21 13:47:53

您可以查看以下链接,并点赞页面以查看更多信息:
https://www.facebook.com/pages /M%C3%A3-Ngu%E1%BB%93n/371039113001844

You can see below link, and like page to see more:
https://www.facebook.com/pages/M%C3%A3-Ngu%E1%BB%93n/371039113001844

荒人说梦 2024-10-21 13:47:53

尝试 PushSharp:
https://github.com/Redth/PushSharp

这对我来说非常有用。

Try PushSharp:
https://github.com/Redth/PushSharp

It worked great for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文