Xamarin.Android 前台服务
本文最后更新于 222 天前,其中的信息可能已经有所发展或是发生改变。
public const string CHANNEL_ID = "default_channel";
public const string CHANNEL_NAME = "Default Channel";
public const int NOTIFICATION_ID = 10000;

public override StartCommandResult OnStartCommand(Intent? intent, StartCommandFlags flags, int startId)
{
    if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
    {
        ((NotificationManager)GetSystemService(NotificationService))
            .CreateNotificationChannel(new(CHANNEL_ID, CHANNEL_NAME, NotificationImportance.Default));
    }
    var notification = new NotificationCompat.Builder(this, CHANNEL_ID)
        .SetContentTitle(GetString(Resource.String.app_name))
        .SetContentText(GetString(Resource.String.app_text))
        .SetSmallIcon(Resource.Mipmap.appicon)
        .Build();
    StartForeground(NOTIFICATION_ID, notification);
    return StartCommandResult.Sticky;
}
作者:AlexSJC
本文采用 CC BY-NC-ND 4.0 许可协议
暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇