public override void OnReceive(Context context, Intent intent) { var extra = intent.GetStringExtra(LocalNotificationKey); var notification = DeserializeNotification(extra); //Generating notification var builder = new NotificationCompat.Builder(Application.Context, channelId) .SetContentTitle(notification.Title) .SetContentText(notification.Body) .SetSmallIcon(notification.IconId) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Ringtone)) .SetAutoCancel(true); var resultIntent = LocalNotificationService.GetLauncherActivity(); resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(Application.Context); stackBuilder.AddNextIntent(resultIntent); Random random = new Random(); int randomNumber = random.Next(9999 - 1000) + 1000; var resultPendingIntent = stackBuilder.GetPendingIntent(randomNumber, (int)PendingIntentFlags.Immutable); builder.SetContentIntent(resultPendingIntent); // Sending notification var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(randomNumber, builder.Build()); }
void SendNotification(string messageBody, IDictionary <string, string> data) { var intent = new Intent(this, typeof(WelcomeActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, MainActivity.NOTIFICATION_ID, intent, PendingIntentFlags.CancelCurrent); var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetSmallIcon(Resource.Drawable.round_notification_important_black_24) .SetContentTitle("FCM Message") .SetContentText(messageBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var notificationManager = NotificationManagerCompat.From(this); notificationManager.Notify(MainActivity.NOTIFICATION_ID, notificationBuilder.Build()); }
private void CreateNotification(SongBundle song) { Log(Type.Info, "Creating notification"); Intent info = new Intent(Application.Context, typeof(MainActivity)); info.PutExtra("NotificationSong", JsonConvert.SerializeObject(song)); TaskStackBuilder stackBuilder = TaskStackBuilder.Create(Application.Context); stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity))); stackBuilder.AddNextIntent(info); PendingIntent resultIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, ChannelId) .SetAutoCancel(true) .SetContentTitle(Resources?.GetString(Resource.String.app_name)) .SetContentText(song.Normal.Artist + " - " + song.Normal.Title) .SetSmallIcon(Resource.Drawable.ic_stat_name) .SetContentIntent(resultIntent) .SetPriority(-1); ntfManager = NotificationManagerCompat.From(Application.Context); ntfManager.Notify(NotificationId, builder.Build()); Log(Type.Event, "Notification made!"); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var v = FindViewById <WatchViewStub>(Resource.Id.watch_view_stub); v.LayoutInflated += delegate { // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.myButton); button.Click += delegate { var notification = new NotificationCompat.Builder(this) .SetContentTitle("Button tapped") .SetContentText("Button tapped " + count++ + " times!") .SetSmallIcon(Android.Resource.Drawable.StatNotifyVoicemail) .SetGroup("group_key_demo").Build(); var manager = NotificationManagerCompat.From(this); manager.Notify(1, notification); button.Text = "Check Notification!"; }; }; }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="intent"></param> public override void OnReceive(Context context, Intent intent) { var extra = intent.GetStringExtra(LocalNotificationKey); var notification = DeserializeNotification(extra); var builder = new NotificationCompat.Builder(Application.Context) .SetContentTitle(notification.Title) .SetContentText(notification.Body) .SetSmallIcon(notification.IconId) .SetAutoCancel(true); var resultIntent = LocalNotificationsImplementation.GetLauncherActivity(); resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(Application.Context); stackBuilder.AddNextIntent(resultIntent); var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent); builder.SetContentIntent(resultPendingIntent); var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(notification.Id, builder.Build()); }
public void CancelAll() { var context = AndroidApplication.Context; var manager = NotificationManagerCompat.From(context); manager.CancelAll(); }
private static void BuildNotification(Context context, int notifyId, string channel, string title, string content, Intent intent) { Log.Error("PPPAAAAAAAAAAAAAAAAAA", "build notification for " + title + " with id: " + notifyId); PendingIntent piNotification = PendingIntent.GetActivity(context, notifyId, intent, PendingIntentFlags.UpdateCurrent); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, channel) .SetSmallIcon(Resource.Drawable.water) .SetContentText(content) .SetContentTitle(title) .SetAutoCancel(true) .SetContentIntent(piNotification) .SetPriority(NotificationCompat.PriorityHigh); if (title.Equals(TITLE_BLOODPRESSURE)) { mBuilder.SetSmallIcon(Resource.Drawable.heart); } else { mBuilder.SetSmallIcon(Resource.Drawable.water); } NotificationManagerCompat notificationManager = NotificationManagerCompat.From(context); notificationManager.Notify(notifyId, mBuilder.Build()); }
public void UpdateNotifications(IMediaFile mediaFile, MediaPlayerStatus status) { try { var isPlaying = status == MediaPlayerStatus.Playing || status == MediaPlayerStatus.Buffering; var isPersistent = status == MediaPlayerStatus.Playing || status == MediaPlayerStatus.Buffering || status == MediaPlayerStatus.Paused; var nm = NotificationManagerCompat.From(_applicationContext); if (nm != null && _builder != null) { SetMetadata(mediaFile); AddActionButtons(isPlaying); _builder.SetOngoing(isPersistent); //nm.Notify(_notificationId, _builder.Build()); } else { StartNotification(mediaFile, isPlaying, false); } } catch (Exception ex) { Console.WriteLine(ex.Message); StopNotifications(); } }
/// <summary> /// Show a local notification /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> public void Show(string title, string body, int id = 0) { var builder = new NotificationCompat.Builder(Application.Context); builder.SetContentTitle(title); builder.SetContentText(body); builder.SetAutoCancel(true); if (NotificationIconId != 0) { builder.SetSmallIcon(NotificationIconId); } else { builder.SetSmallIcon(Resource.Drawable.plugin_lc_smallicon); } var resultIntent = GetLauncherActivity(); resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); resultIntent.PutExtra(LocalNotificationIntentKey, id); var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(Application.Context); stackBuilder.AddNextIntent(resultIntent); var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent); builder.SetContentIntent(resultPendingIntent); var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(id, builder.Build()); }
void SendNotification(string messageBody, IDictionary <string, string> data) { var intent = new Intent(this, typeof(NotificationActivitity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, NotificationActivitity.NOTIFICATION_ID, intent, PendingIntentFlags.OneShot); var notificationBuilder = new NotificationCompat.Builder(this) .SetSmallIcon(Resource.Mipmap.ic_launcher) .SetContentTitle("Wanunuzi.com") .SetContentText(messageBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var notificationManager = NotificationManagerCompat.From(this); notificationManager.Notify(NotificationActivitity.NOTIFICATION_ID, notificationBuilder.Build()); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="intent"></param> public override void OnReceive(Context context, Intent intent) { var extra = intent.GetStringExtra(LocalNotificationsImplementation.LocalNotificationKey); var notification = DeserializeNotification(extra); var builder = new NotificationCompat.Builder(Application.Context) .SetContentTitle(notification.Title) .SetContentText(notification.Body) .SetSmallIcon(notification.IconId) .SetAutoCancel(true); var resultIntent = string.IsNullOrEmpty(LocalNotificationsImplementation.LocalNotificationIntentAction) ? LocalNotificationsImplementation.GetLauncherActivity() : new Intent(LocalNotificationsImplementation.LocalNotificationIntentAction).AddFlags(ActivityFlags.NewTask); resultIntent.PutExtra(LocalNotificationsImplementation.LocalNotificationIntentKey, notification.Id); var resultPendingIntent = PendingIntent.GetActivity(Application.Context, 0, resultIntent, 0); builder.SetContentIntent(resultPendingIntent); var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(notification.Id, builder.Build()); }
public override void OnReceive(Context context, Intent intent) { var message = intent.GetStringExtra("message"); var title = intent.GetStringExtra("title"); var notIntent = new Intent(context, typeof(MainScreen)); var contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent); var manager = NotificationManagerCompat.From(context); var style = new NotificationCompat.BigTextStyle(); style.BigText(message); int resourceId = Resource.Drawable.HappyBaby; var wearableExtender = new NotificationCompat.WearableExtender() .SetBackground(BitmapFactory.DecodeResource(context.Resources, resourceId)); //Generate a notification with just short text and small icon var builder = new NotificationCompat.Builder(context) .SetContentIntent(contentIntent) .SetSmallIcon(Resource.Drawable.HappyBaby) .SetSound(Android.Net.Uri.Parse("android.resource://com.iinotification.app/" + Resource.Raw.babySound)) .SetContentTitle("Hey Mom") .SetContentText("Here I'm :)") .SetStyle(style) .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()) .SetAutoCancel(true) .Extend(wearableExtender); var notification = builder.Build(); manager.Notify(0, notification); }
private void SendNotification(string title, string messageBody, IDictionary <string, string> data) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, MainActivity.NOTIFICATION_ID, intent, PendingIntentFlags.OneShot); var bitMap = BitmapFactory.DecodeResource(Resources, Mipmap.ic_launcher_notification); var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetSmallIcon(Mipmap.ic_launcher) .SetLargeIcon(bitMap) .SetContentTitle(title) .SetContentText(messageBody) .SetContentIntent(pendingIntent) .SetVisibility((int)NotificationVisibility.Public) .SetDefaults(NotificationCompat.DefaultAll) .SetPriority(NotificationCompat.PriorityHigh); var notificationManager = NotificationManagerCompat.From(this); notificationManager.Notify(MainActivity.NOTIFICATION_ID, notificationBuilder.Build()); }
private void PushNotifications(Context context, string title, string text) { // Create PendingIntent Intent map_intent = new Intent(context, typeof(MainActivity2)); PendingIntent resultPendingIntent = PendingIntent.GetActivity(context, 0, map_intent, PendingIntentFlags.UpdateCurrent); //Create Notification NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID) .SetSmallIcon(Resource.Mipmap.ic_launcher) .SetContentTitle(title) .SetContentText(text) .SetAutoCancel(true) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Ringtone)) .SetVibrate(new long[] { 1000, 1000 }) .SetContentIntent(resultPendingIntent); //Show Notification Notification notification = builder.Build(); NotificationManagerCompat notificationManager = NotificationManagerCompat.From(context); var str = notificationManager.AreNotificationsEnabled(); //NotificationManager notificationManager = context.GetSystemService(Context.NotificationService) as NotificationManager; notificationManager.Notify(NOTIFY_ID, notification); }
private void btnSendNotificationWithWearableOnlyaAction_OnClick(object sender, EventArgs eventArgs) { // Build intent for notification content var pendingIntent = new Intent(Context, typeof(AndroidWearStep1ActivityExtraIntent)); pendingIntent.PutExtra("EXTRA_EVENT_ID", 2); var viewPendingIntent = PendingIntent.GetActivity(Context, 0, pendingIntent, 0); // Build action intent var mapIntent = new Intent(Intent.ActionView); mapIntent.SetData(Android.Net.Uri.Parse("geo:51.2195163,4.4156713,17")); var actionPendingIntent = PendingIntent.GetActivity(Context, 0, mapIntent, 0); // Build wearable only action intent var wearableMapIntent = new Intent(Intent.ActionView); wearableMapIntent.SetData(Android.Net.Uri.Parse("geo:22.280260, 114.173885")); var wearableActionPendingIntent = PendingIntent.GetActivity(Context, 0, wearableMapIntent, 0); var builder = new NotificationCompat.Builder(Context); builder.SetContentTitle("Notification") .SetContentText("With Extra Action") .SetLocalOnly(false) .SetSmallIcon(Resource.Drawable.icon6) .SetContentIntent(viewPendingIntent) .AddAction(Resource.Drawable.icon6action, "Etra Action Title", actionPendingIntent) .Extend( new NotificationCompat.WearableExtender() .AddAction(new NotificationCompat.Action(Resource.Drawable.icon6action, "Wearable Only", wearableActionPendingIntent))); NotificationManagerCompat.From(Context).Notify(115, builder.Build()); }
public override bool OnStartJob(IJobParameters jobParameters) { Log.Error("lv", "11111111111111111111111"); Intent notIntent = new Intent(this, typeof(MainActivity)); PendingIntent contentIntent = PendingIntent.GetActivity(this, 0, notIntent, PendingIntentFlags.UpdateCurrent); NotificationManagerCompat manager = NotificationManagerCompat.From(this); var wearableExtender = new NotificationCompat.WearableExtender().SetBackground(BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.pause)); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .SetContentIntent(contentIntent) .SetSmallIcon(Resource.Drawable.play) .SetContentTitle("title") .SetContentText("message") .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) .Extend(wearableExtender); Notification notification = builder.Build(); notification.Flags = NotificationFlags.AutoCancel; manager.Notify(0, notification); JobFinished(jobParameters, false); return(true); }
private void btnSendNotificationWithVoiceInput_OnClick(object sender, EventArgs eventArgs) { // Key for the string that's delivered in the action's intent var replyChoices = new string[] { "Choice 1", "Choice 2" }; var remoteInput = new Android.Support.V4.App.RemoteInput.Builder(EXTRA_VOICE_REPLY) .SetLabel("Reply") .SetChoices(replyChoices) .Build(); // Build intent for notification content var pendingIntent = new Intent(Context, typeof(AndroidWearStep1ActivityExtraIntent)); pendingIntent.PutExtra("EXTRA_EVENT_ID", 2); var viewPendingIntent = PendingIntent.GetActivity(Context, 0, pendingIntent, PendingIntentFlags.UpdateCurrent); // Create the reply action and add the remote input var action = new NotificationCompat.Action.Builder(Resource.Drawable.ic_media_play, "Reply!", viewPendingIntent) .AddRemoteInput(remoteInput) .Build(); // Build the notification and add the action via WearableExtender var notification = new NotificationCompat.Builder(Context) .SetSmallIcon(Resource.Drawable.icon9) .SetContentTitle("Notification") .SetContentText("With Voice Input Action") .Extend(new NotificationCompat.WearableExtender().AddAction(action)) .Build(); NotificationManagerCompat.From(Context).Notify(118, notification); }
private void SendNotification(string title, string body, IDictionary <string, string> data) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, MainActivity.NOTIFICATION_ID, intent, PendingIntentFlags.OneShot); var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetSmallIcon(Resource.Mipmap.launcher_foreground) .SetContentTitle(title) .SetContentText(body) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var notificationManager = NotificationManagerCompat.From(this); var notification = notificationBuilder.Build(); notificationManager.Notify(MainActivity.NOTIFICATION_ID, notification); }
public bool registeredForNotifications() { var nm = NotificationManagerCompat.From(Android.App.Application.Context); bool enabled = nm.AreNotificationsEnabled(); return(enabled); }
public override void OnMessageReceived(RemoteMessage remoteMessage) { base.OnMessageReceived(remoteMessage); var userLoggedIn = CommonService.GetFromSharedPreferences <bool>(Application.Context, Constants.AppConfig.UserLoggedIn); if (!userLoggedIn) { return; } var notification = GetNotification(remoteMessage); var droidNotification = new NotificationCompat.Builder(Application.Context, Constants.AppConfig.FCMChannelID) .SetContentTitle(notification.Title) .SetContentText(notification.Content) .SetSmallIcon(Resource.Drawable.ic_stat_bdc) .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Mipmap.ic_launcher)) .SetContentIntent(GetPendingIntent(notification)) .SetPriority(NotificationCompat.PriorityHigh) .SetAutoCancel(true) .Build(); var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(DateTime.Now.Millisecond, droidNotification); Publish(notification); }
private void SendNotification(string messageBody, IDictionary <string, string> data) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot); var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetSmallIcon(Resource.Drawable.notification_template_icon_bg) .SetContentTitle("NDK Notification") .SetContentText(messageBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var notificationManager = NotificationManagerCompat.From(this); notificationManager.Notify(Guid.NewGuid().ToString().GetHashCode(), notificationBuilder.Build()); }
private void SetNotification() { Log.Debug(TAG, "SetNotification()"); CreateNotificationChannel(); var text = "Controller notification enabled."; notification_receiver = new NotificationReceiver(); var pFilter = new IntentFilter(NotificationReceiver.ACTION_SHOW); RegisterReceiver(notification_receiver, pFilter); Intent notificationIntent = new Intent(NotificationReceiver.ACTION_SHOW); PendingIntent contentIntent = PendingIntent.GetBroadcast(Application.Context, 1, notificationIntent, 0); String title = "Show SoftWing Controller"; String body = "Select this to open the controller."; NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID) .SetSmallIcon(Resource.Mipmap.ic_launcher_foreground) .SetColor(Resource.Color.accent_material_dark) .SetAutoCancel(false) .SetTicker(text) .SetContentTitle(title) .SetContentText(body) .SetContentIntent(contentIntent) .SetOngoing(true) .SetVisibility((int)NotificationVisibility.Public) .SetPriority(NotificationCompat.PriorityDefault); NotificationManagerCompat notificationManager = NotificationManagerCompat.From(this); StartForeground(NOTIFICATION_ONGOING_ID, mBuilder.Build()); }
void SendNotification(string messageBody, IDictionary <string, string> data) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, MainActivity.NOTIFICATION_ID, intent, PendingIntentFlags.OneShot); // Building notification var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetSmallIcon(Resource.Mipmap.icon) .SetContentTitle("FCM Message") .SetContentText(messageBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent); // Crete the Notification Manager var notificationManager = NotificationManagerCompat.From(this); // Notifys notificationManager.Notify(MainActivity.NOTIFICATION_ID, notificationBuilder.Build()); }
public override void OnReceive(Context context, Intent intent) { var extra = intent.GetStringExtra(LocalNotificationKey); var notification = DeserializeNotification(extra); Android.Net.Uri alarmUri = Android.Net.Uri.Parse($"{ ContentResolver.SchemeAndroidResource}://{context.PackageName}/{Resource.Raw.quds}"); //Generating notification var builder = new NotificationCompat.Builder(Application.Context) .SetContentTitle(notification.Title) .SetContentText(notification.Body) .SetSmallIcon(notification.IconId) .SetSound(alarmUri) .SetAutoCancel(true); var resultIntent = LocalNotificationService.GetLauncherActivity(); resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); var stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(Application.Context); stackBuilder.AddNextIntent(resultIntent); Random random = new Random(); int randomNumber = random.Next(9999 - 1000) + 1000; var resultPendingIntent = stackBuilder.GetPendingIntent(randomNumber, (int)PendingIntentFlags.Immutable); builder.SetContentIntent(resultPendingIntent); // Sending notification var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(randomNumber, builder.Build()); }
void SendNotification(string messageBody, IDictionary <string, string> data, string tittle) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, MainActivity.NOTIFICATION_ID, intent, PendingIntentFlags.OneShot); var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetContentTitle(tittle) .SetContentText(messageBody) .SetAutoCancel(true) .SetPriority((int)NotificationPriority.High) .SetVibrate(new long[0]) .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate) .SetVisibility((int)NotificationVisibility.Public) .SetSmallIcon(Resource.Drawable.logo) .SetContentIntent(pendingIntent); var notificationManager = NotificationManagerCompat.From(this); notificationManager.Notify(MainActivity.NOTIFICATION_ID, notificationBuilder.Build()); }
// 앱이 백그라운드 상태에 있다면 시스템 트레이를 통하여 Notificiation이 표시가되고 포어그라운드 상태에 있다면 onMessageReceived를 통해 데이터가 처리됩니다. void SendNotification(string messageTitle, string messageBody, IDictionary <string, string> data) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); foreach (var key in data.Keys) { intent.PutExtra(key, data[key]); } var pendingIntent = PendingIntent.GetActivity(this, MainActivity.NOTIFICATION_ID, intent, PendingIntentFlags.OneShot); var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID) .SetSmallIcon(Resource.Drawable.abc_ic_ab_back_material) // 아이콘 .SetContentTitle(messageTitle) .SetContentText(messageBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var notificationManager = NotificationManagerCompat.From(this); notificationManager.Notify(MainActivity.NOTIFICATION_ID, notificationBuilder.Build()); }
public override void OnReceive(Context context, Intent intent) { var message = intent.GetStringExtra("message"); var title = intent.GetStringExtra("title"); var notIntent = new Intent(context, typeof(MainActivity)); var contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent); var manager = NotificationManagerCompat.From(context); var style = new NotificationCompat.BigTextStyle(); style.BigText(message); //Generate a notification with just short text and small icon var builder = new NotificationCompat.Builder(context) .SetContentIntent(contentIntent) .SetSmallIcon(Resource.Drawable.logo) .SetContentTitle(title) .SetContentText(message) .SetStyle(style) .SetWhen(JavaSystem.CurrentTimeMillis()) .SetPriority((int)NotificationPriority.High) .SetDefaults((int)NotificationDefaults.All) .SetAutoCancel(true); var notification = builder.Build(); manager.Notify(0, notification); }
private void ShowNotification() { if (Log.IsLoggable(TAG, LogPriority.Debug)) { Log.Debug(TAG, "Sent: " + mLastResponse); } var builder = new NotificationCompat.Builder(this) .SetContentTitle(GetString(Resource.String.eliza)) .SetContentText(mLastResponse) .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.bg_eliza)) .SetSmallIcon(Resource.Drawable.bg_eliza) .SetPriority(NotificationCompat.PriorityMin); var intent = new Intent(ACTION_RESPONSE); var pendingIntent = PendingIntent.GetService(this, 0, intent, PendingIntentFlags.OneShot | PendingIntentFlags.CancelCurrent); var notification = builder .Extend(new NotificationCompat.WearableExtender() .AddAction(new NotificationCompat.Action.Builder (Resource.Drawable.ic_full_reply, GetString(Resource.String.reply), pendingIntent) .AddRemoteInput(new RemoteInput.Builder(EXTRA_REPLY).SetLabel(GetString(Resource.String.reply)).Build()) .Build())) .Build(); NotificationManagerCompat.From(this).Notify(NOTIFICATION_ID, notification); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Step2); // Build intent for notification content var pendingIntent = new Intent(this, typeof(MainActivity)); pendingIntent.PutExtra("EXTRA_EVENT_ID", 2); var viewPendingIntent = PendingIntent.GetActivity(this, 0, pendingIntent, 0); var notificationIntent = new Intent(this, typeof(NotificationWithExtraActivity)); var notificationPendingIntent = PendingIntent.GetActivity( this, 0, notificationIntent, PendingIntentFlags.UpdateCurrent); var builder = new NotificationCompat.Builder(this); builder.SetContentTitle("Notification") .SetContentText("With Custom Wearable Display Activity") .SetLocalOnly(false) .SetSmallIcon(Resource.Drawable.ic_full_sad) .SetContentIntent(viewPendingIntent) .Extend( new NotificationCompat.WearableExtender() .SetDisplayIntent(notificationPendingIntent)); NotificationManagerCompat.From(this).Notify(201, builder.Build()); }
/// <summary> /// Show a local notification /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> public void Show(string title, string body, int id = 0) { var builder = new NotificationCompat.Builder(Application.Context); builder.SetContentTitle(title); builder.SetContentText(body); builder.SetAutoCancel(true); if (NotificationIconId != 0) { builder.SetSmallIcon(NotificationIconId); } else { builder.SetSmallIcon(Resource.Drawable.plugin_lc_smallicon); } var resultIntent = string.IsNullOrEmpty(LocalNotificationIntentAction) ? GetLauncherActivity() : new Intent(LocalNotificationIntentAction).AddFlags(ActivityFlags.NewTask); resultIntent.PutExtra(LocalNotificationIntentKey, id); var resultPendingIntent = PendingIntent.GetActivity(Application.Context, 0, resultIntent, PendingIntentFlags.UpdateCurrent); builder.SetContentIntent(resultPendingIntent); var notificationManager = NotificationManagerCompat.From(Application.Context); notificationManager.Notify(id, builder.Build()); }
public override void OnCreate () { Log.Debug (TAG, "onCreate"); mNotificationManager = NotificationManagerCompat.From (ApplicationContext); }
public override void OnCreate () { binder.RService = this; notificationManager = NotificationManagerCompat.From (this); Last = this; }