/// <summary> /// Builds a Notification.Action that will instruct the service to restart the timer. /// </summary> /// <returns>The restart timer action.</returns> private Notification.Action BuildRestartTimerAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction(Constants.ActionRestartTimer); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.EditText, "Restart Timer", restartTimerPendingIntent); return(builder.Build()); }
/// <summary> /// Builds the Notification.Action that will allow the user to stop the service via the /// notification in the status bar /// </summary> /// <returns>The stop service action.</returns> private Notification.Action BuildStopServiceAction() { var stopServiceIntent = new Intent(this, GetType()); stopServiceIntent.SetAction(Constants.ActionStopService); var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.IcMediaPause, "Stop Service", stopServicePendingIntent); return(builder.Build()); }
/// <summary> /// Builds the ability to stop the TrackingService by pressing the "Stop Tracking" button on the notification /// </summary> /// <returns></returns> Notification.Action BuildStopServiceAction() { var stopServiceIntent = new Intent(this, GetType()); stopServiceIntent.SetAction("TheOxbridgeApp.action.STOP_SERVICE"); var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.IcMediaPause, "Stop tracking", stopServicePendingIntent); return(builder.Build()); }
// /// <summary> ///// Builds a PendingIntent that will display the main activity of the app. This is used when the ///// user taps on the notification; it will take them to the main activity of the app. ///// </summary> ///// <returns>The content intent.</returns> //PendingIntent BuildIntentToShowMainActivity() // { // var notificationIntent = new Intent(this, typeof(MainActivity)); // notificationIntent.SetAction("ServicesDemo3.action.MAIN_ACTIVITY"); // notificationIntent.SetFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTask); // notificationIntent.PutExtra("has_service_been_started", true); // var pendingIntent = PendingIntent.GetActivity(this, 0, notificationIntent, PendingIntentFlags.UpdateCurrent); // return pendingIntent; // } /// <summary> /// Builds a Notification.Action that will instruct the service to restart the timer. /// </summary> /// <returns>The restart timer action.</returns> private Notification.Action StopTimerAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction("STOP_TIMER"); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(Resource.Drawable.ic_action_stop, GetText(Resource.String.stop), restartTimerPendingIntent); return(builder.Build()); }
/// <summary> /// Builds a Notification.Action that will instruct the service to restart the timer. /// </summary> /// <returns>The restart timer action.</returns> Notification.Action BuildRestartTimerAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction(Constants.ACTION_RESTART_TIMER); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(Resource.Drawable.ic_mtrl_chip_checked_circle, "Restart", restartTimerPendingIntent); return(builder.Build()); }
/// <summary> /// Builds the Notification.Action that will allow the user to stop the service via the /// notification in the status bar /// </summary> /// <returns>The stop service action.</returns> Notification.Action BuildStopServiceAction() { var stopServiceIntent = new Intent(this, GetType()); stopServiceIntent.SetAction(Constants.ACTION_STOP_SERVICE); var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.IcMediaPause, GetText(HaxOnTheWay.Droid.Resource.String.stop_service), stopServicePendingIntent); return(builder.Build()); }
/// <summary> /// Builds a Notification.Action that will instruct the service to restart the timer. /// </summary> /// <returns>The restart timer action.</returns> Notification.Action BuildRestartTimerAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction(Constants.ACTION_RESTART_TIMER); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(HaxOnTheWay.Droid.Resource.Drawable.ic_action_restart_timer, GetText(HaxOnTheWay.Droid.Resource.String.restart_timer), restartTimerPendingIntent); return(builder.Build()); }
/// <summary> /// Запускает действие, которое позволяет завершить работу сервиса /// </summary> /// <returns>Действие завершения сервиса</returns> Notification.Action BuildStopServiceAction() { var stopServiceIntent = new Intent(this, GetType()); stopServiceIntent.SetAction("MyNotes.action.STOP_SERVICE"); var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.IcMediaPause, GetText(Resource.String.stop_service), stopServicePendingIntent); return(builder.Build()); }
Notification.Action BuildTestAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction("ACTION_TEST"); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(Resource.Drawable.abc_btn_check_material, "Ttttest", restartTimerPendingIntent); return(builder.Build()); }
/// <summary> /// Builds a Notification.Action that will instruct the service to restart the timer. /// </summary> /// <returns>The restart timer action.</returns> Notification.Action BuildRestartTimerAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction(Constants.ACTION_RESTART_TIMER); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(Resource.Mipmap.ic_launcher, GetText(Resource.String.restart_timestamp_service_button_text), restartTimerPendingIntent); return(builder.Build()); }
/// <summary> /// Builds the Notification.Action that will allow the user to stop the service via the /// notification in the status bar /// </summary> /// <returns>The stop service action.</returns> Notification.Action BuildStopServiceAction() { var stopServiceIntent = new Intent(this, GetType()); stopServiceIntent.SetAction(Constants.ACTION_STOP_SERVICE); var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.IcMediaPause, "Stop Timer", stopServicePendingIntent); StopForeground(true); return(builder.Build()); }
public static void SendDumbNotification() { NotificationManager notificationManager = (NotificationManager)Application.Context.GetSystemService("notification"); Notification.Builder builder; if (Build.VERSION.SdkInt < BuildVersionCodes.NMr1) { #pragma warning disable CS0618 // 'Notification.Builder.SetPriority(int)' está obsoleto: 'deprecated' builder = new Notification.Builder(Application.Context); builder.SetPriority(Convert.ToInt32(NotificationPriority.Max)); #pragma warning restore CS0618 // 'Notification.Builder.SetPriority(int)' está obsoleto: 'deprecated' } else { NotificationChannel notificationChannel = new NotificationChannel("livedisplaynotificationchannel", "LiveDisplay", NotificationImportance.Max); notificationManager.CreateNotificationChannel(notificationChannel); builder = new Notification.Builder(Application.Context, "livedisplaynotificationchannel"); } RemoteInput remoteInput = new RemoteInput.Builder("test1").SetLabel("This is the place where you write").Build(); Intent intent = new Intent(Application.Context, Java.Lang.Class.FromType(typeof(MainActivity))); PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, 35, intent, PendingIntentFlags.UpdateCurrent); Notification.Action.Builder action = new Notification.Action.Builder(Resource.Drawable.ic_stat_default_appicon, "Answer", pendingIntent).AddRemoteInput(remoteInput); builder.SetStyle(new Notification.MessagingStyle("Su madre").AddMessage(new Notification.MessagingStyle.Message("hi", -1, "user1")) .AddMessage(new Notification.MessagingStyle.Message("WhatsUp", 0, "user2")) .AddMessage(new Notification.MessagingStyle.Message("How bout lunch?", 1, "user1"))); #pragma warning restore builder.SetContentTitle(""); builder.SetContentText(""); builder.SetAutoCancel(true); builder.AddAction(action.Build()); builder.SetSmallIcon(Resource.Drawable.ic_stat_default_appicon); notificationManager.Notify(2, builder.Build()); }
public void PostNotification(int notifid, string title, string text, bool autoCancellable, NotificationImportance notificationImportance) { NotificationChannel notificationChannel = new NotificationChannel("livedisplaynotificationchannel", "LiveDisplay", notificationImportance); notificationManager.CreateNotificationChannel(notificationChannel); Notification.Builder builder = new Notification.Builder(Application.Context, "livedisplaynotificationchannel"); builder.SetContentTitle(title); builder.SetContentText(text); builder.SetAutoCancel(autoCancellable); builder.SetSmallIcon(Resource.Drawable.ic_stat_default_appicon); builder.SetAutoCancel(true); RemoteInput remoteInput = new RemoteInput.Builder("test1").SetLabel("This is the place where you write").Build(); Intent intent = new Intent(Application.Context, Java.Lang.Class.FromType(typeof(SettingsActivity))); PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, 35, intent, PendingIntentFlags.UpdateCurrent); Notification.Action.Builder action = new Notification.Action.Builder(Resource.Drawable.ic_stat_default_appicon, "Answer", pendingIntent).AddRemoteInput(remoteInput); builder.AddAction(action.Build()); notificationManager.Notify(notifid, builder.Build()); }
/// <summary> /// Builds the Notification.Action that will allow the user to stop the service via the /// notification in the status bar /// </summary> /// <returns>The stop service action.</returns> Notification.Action BuildStopServiceAction() { var stopServiceIntent = new Intent(this, GetType()); stopServiceIntent.SetAction(Constants.ACTION_STOP_SERVICE); var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0); var builder = new Notification.Action.Builder(Android.Resource.Drawable.IcMediaPause, GetText(Resource.String.stop_service), stopServicePendingIntent); return builder.Build(); }
/// <summary> /// Builds a Notification.Action that will instruct the service to restart the timer. /// </summary> /// <returns>The restart timer action.</returns> Notification.Action BuildRestartTimerAction() { var restartTimerIntent = new Intent(this, GetType()); restartTimerIntent.SetAction(Constants.ACTION_RESTART_TIMER); var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0); var builder = new Notification.Action.Builder(Resource.Drawable.ic_action_restart_timer, GetText(Resource.String.restart_timer), restartTimerPendingIntent); return builder.Build(); }