public Notification Build(Builder b) { Notification.Builder builder = new Notification.Builder(b.Context); builder.SetContentTitle(b.ContentTitle) .SetContentText(b.ContentText) .SetTicker(b.Notification.TickerText) .SetSmallIcon(b.Notification.Icon, b.Notification.IconLevel) .SetContentIntent(b.ContentIntent) .SetDeleteIntent(b.Notification.DeleteIntent) .SetAutoCancel((b.Notification.Flags & NotificationFlags.AutoCancel) != 0) .SetLargeIcon(b.LargeIcon) .SetDefaults(b.Notification.Defaults); if (b.Style != null) { if (b.Style is BigTextStyle) { BigTextStyle staticStyle = b.Style as BigTextStyle; Notification.BigTextStyle style = new Notification.BigTextStyle(builder); style.SetBigContentTitle(staticStyle.BigContentTitle) .BigText(staticStyle.bigText); if (staticStyle.SummaryTextSet) { style.SetSummaryText(staticStyle.SummaryText); } } } return builder.Build(); }
public void DisplayNotificationIfNextGameIsToday(IList<Fixture> fixtures) { //var now = new DateTime(2014, 9, 14, 15, 00, 00); var now = DateTime.Now; var fixture = fixtures[0]; var notificationManager = (NotificationManager)_context.GetSystemService(Context.NOTIFICATION_SERVICE); if (fixture.Date.Date == now.Date && now <= fixture.Date) { var bigText = new Notification.BigTextStyle(); bigText.BigText(fixture.HomeTeam + " v " + fixture.AwayTeam); var footballTodayMessage = "Football today at " + fixture.Date.ToString("HH:mm"); bigText.SetBigContentTitle(footballTodayMessage); var notification = new Notification.Builder(_context) .SetSmallIcon(R.Drawables.Icon) .SetStyle(bigText) .SetTicker(footballTodayMessage) .Build(); notificationManager.Notify(1, notification); } else { notificationManager.CancelAll(); } }
public void DisplayNotificationIfNextGameIsToday(IList <Fixture> fixtures) { //var now = new DateTime(2014, 9, 14, 15, 00, 00); var now = DateTime.Now; var fixture = fixtures[0]; var notificationManager = (NotificationManager)_context.GetSystemService(Context.NOTIFICATION_SERVICE); if (fixture.Date.Date == now.Date && now <= fixture.Date) { var bigText = new Notification.BigTextStyle(); bigText.BigText(fixture.HomeTeam + " v " + fixture.AwayTeam); var footballTodayMessage = "Football today at " + fixture.Date.ToString("HH:mm"); bigText.SetBigContentTitle(footballTodayMessage); var notification = new Notification.Builder(_context) .SetSmallIcon(R.Drawables.Icon) .SetStyle(bigText) .SetTicker(footballTodayMessage) .Build(); notificationManager.Notify(1, notification); } else { notificationManager.CancelAll(); } }
public Notification Build(Builder b) { Notification.Builder builder = new Notification.Builder(b.Context); builder.SetContentTitle(b.ContentTitle) .SetContentText(b.ContentText) .SetTicker(b.Notification.TickerText) .SetSmallIcon(b.Notification.Icon, b.Notification.IconLevel) .SetContentIntent(b.ContentIntent) .SetDeleteIntent(b.Notification.DeleteIntent) .SetAutoCancel((b.Notification.Flags & NotificationFlags.AutoCancel) != 0) .SetLargeIcon(b.LargeIcon) .SetDefaults(b.Notification.Defaults); if (b.Style != null) { if (b.Style is BigTextStyle) { BigTextStyle staticStyle = b.Style as BigTextStyle; Notification.BigTextStyle style = new Notification.BigTextStyle(builder); style.SetBigContentTitle(staticStyle.BigContentTitle) .BigText(staticStyle.bigText); if (staticStyle.SummaryTextSet) { style.SetSummaryText(staticStyle.SummaryText); } } } return(builder.Build()); }
public void checkchange() { while (true) { IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress ip in localIPs) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { if (ipadre != ip.ToString()) { servidor.Stop(); ipadre = ip.ToString(); servidor = new MultitubeWebServer(Android.OS.Environment.ExternalStorageDirectory.ToString(), 12345, ipadre, this); var brandom = new Random(); Intent internado2 = new Intent(this, typeof(serviciointerpreter23)); Intent internado3 = new Intent(this, typeof(serviciointerpreter234)); var pendingIntent3 = PendingIntent.GetService(ApplicationContext, brandom.Next(2000, 50000) + brandom.Next(2000, 50000), internado3, 0); var pendingIntent2 = PendingIntent.GetService(ApplicationContext, brandom.Next(2000, 50000) + brandom.Next(2000, 50000), internado2, 0); Notification.Action accion = new Notification.Action(Resource.Drawable.drwaable, "Parar", pendingIntent2); Notification.Action accion2 = new Notification.Action(Resource.Drawable.drwaable, "Conectarse", pendingIntent3); Notification.BigTextStyle textoo = new Notification.BigTextStyle(); textoo.SetBigContentTitle("Stremeando en " + ipadre + ":12345"); textoo.SetSummaryText("Toque para parar de stremear su media"); textoo.BigText("Para conectarse introduzca " + ipadre + ":12345 " + "en su navegador o entre a multitubeweb.tk y toque conectar luego escanee el codigo que aparece al presionar el boton de + en multitubeweb. al tocar parar se cierrar el servicio de streaming"); #pragma warning disable CS0618 // El tipo o el miembro están obsoletos Notification.Builder nBuilder = new Notification.Builder(this); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos nBuilder.SetContentTitle("Stremeando en " + ipadre + ":12345"); nBuilder.SetContentText("Toque para parar de stremear su media"); nBuilder.SetStyle(textoo); nBuilder.SetColor(Android.Graphics.Color.DarkRed.ToArgb()); nBuilder.SetOngoing(true); // nBuilder.SetContentIntent(pendingIntent2); nBuilder.SetSmallIcon(Resource.Drawable.antena); nBuilder.AddAction(accion); nBuilder.AddAction(accion2); Notification notification = nBuilder.Build(); StartForeground(193423456, notification); if (CheckInternetConnection() && Constants.UseFirebase) { meterdata(); } } } } MultiHelper.ExecuteGarbageCollection(); Thread.Sleep(5000); } }
private void startMyService() { //create the default activity to be shown Intent intent = new Intent(); PendingIntent pending = PendingIntent.GetActivity(this, 0, intent, 0); if (Android.OS.Build.VERSION.SdkInt <= BuildVersionCodes.NMr1) { var notification = new Notification.Builder(this, Constants.CHANNEL_ID) .SetContentTitle(Constants.CONTENT_TITLE) .SetContentText(Constants.CONTENT_TEXT) .SetSmallIcon(Resource.Drawable.bsplash) .SetOngoing(true) .Build(); StartForeground(300, notification); } else { //create a notification channel. this is a must if your service is going to run on //Android 8.0(Oreo) and above NotificationChannel channel = new NotificationChannel(MPConstants.CHANNEL_ID1, MPConstants.CHANNEL_NAME, NotificationImportance.Default); NotificationManager manager = GetSystemService(NotificationService) as NotificationManager; if (manager != null) { manager.CreateNotificationChannel(channel); } //create the notification var builder = new Notification.Builder(this, MPConstants.CHANNEL_ID1); //make notification show big text Notification.BigTextStyle BigStyle = new Notification.BigTextStyle(); BigStyle.SetBigContentTitle("This service is running in the foreground"); BigStyle.BigText("This is a music like foreground service that was built using some tutorial and some little tweaks"); builder.SetStyle(BigStyle); //build notification builder.SetWhen(DateTime.Now.Millisecond); builder.SetSmallIcon(Resource.Drawable.badge); //////set large icon of type Bitmap //Bitmap LargeIconBitMap = BitmapFactory.DecodeResource(Resources.get, Resource.Drawable.bsplash); //used to set full screen intent builder.SetFullScreenIntent(pending, true); //Add play button to Notification Intent PlayIntent = new Intent(this, typeof(MusicService)); intent.SetAction(MPConstants.ACTION_PLAY); PendingIntent PendingPlayIntent = PendingIntent.GetService(this, 0, PlayIntent, 0); Notification.Action playaction = new Notification.Action(Resource.Drawable.ic_media_play_light, "Play", PendingPlayIntent); builder.AddAction(playaction); //add Pause button to Notification Intent PauseIntent = new Intent(this, typeof(MusicService)); intent.SetAction(MPConstants.ACTION_PAUSE); PendingIntent PausePendingIntent = PendingIntent.GetService(this, 0, PauseIntent, 0); Notification.Action PauseAction = new Notification.Action(Resource.Drawable.ic_media_pause_light, "Pause", PausePendingIntent); builder.AddAction(PauseAction); //build notification Notification notification = builder.Build(); StartForeground(500, notification); } }
public override void OnCreate() { instancia = this; IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress ip in localIPs) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ipadre = ip.ToString(); } } new Thread(() => { if (CheckInternetConnection()) { bool notienenada = false; WebClient cliente = new WebClient(); cliente.DownloadDataAsync(new Uri("https://raw.githubusercontent.com/Gr3gorywolf/Multitube.android/master/Updates/version.gr3v")); cliente.DownloadDataCompleted += (aaa, aaaa) => { string versionsinparsear = Encoding.UTF8.GetString(aaaa.Result); if (!File.Exists(Android.OS.Environment.ExternalStorageDirectory.ToString() + "/.gr3cache/version.gr3v")) { notienenada = true; } if (notienenada) { MultitubeWebHelper.UpdateMultitubeWeb(versionsinparsear); } else { if (versionsinparsear != File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.ToString() + "/.gr3cache/version.gr3v")) { MultitubeWebHelper.UpdateMultitubeWeb(versionsinparsear); } } }; if (Constants.UseFirebase) { meterdata(); } } else { } }).Start(); if (servidor != null) { servidor.Stop(); } servidor = new MultitubeWebServer(Android.OS.Environment.ExternalStorageDirectory.ToString(), 12345, ipadre, this); var pelo = new Thread(() => { checkchange(); }); pelo.IsBackground = true; pelo.Start(); var brandom = new Random(); Intent internado2 = new Intent(this, typeof(serviciointerpreter23)); Intent internado3 = new Intent(this, typeof(serviciointerpreter234)); var pendingIntent3 = PendingIntent.GetService(ApplicationContext, brandom.Next(2000, 50000) + brandom.Next(2000, 50000), internado3, 0); var pendingIntent2 = PendingIntent.GetService(ApplicationContext, brandom.Next(2000, 50000) + brandom.Next(2000, 50000), internado2, 0); Notification.Action accion = new Notification.Action(Resource.Drawable.drwaable, "Parar", pendingIntent2); Notification.Action accion2 = new Notification.Action(Resource.Drawable.drwaable, "Conectarse", pendingIntent3); Notification.BigTextStyle textoo = new Notification.BigTextStyle(); textoo.SetBigContentTitle("Stremeando en " + ipadre + ":12345"); textoo.SetSummaryText("Toque para parar de stremear su media"); textoo.BigText("Para conectarse introduzca " + ipadre + ":12345 " + "en su navegador o entre a multitubeweb.tk y toque conectar luego escanee el codigo que aparece al presionar el boton de + en multitubeweb. al tocar parar se cierrar el servicio de streaming"); #pragma warning disable CS0618 // El tipo o el miembro están obsoletos Notification.Builder nBuilder = new Notification.Builder(this); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos nBuilder.SetContentTitle("Stremeando en " + ipadre + ":12345"); nBuilder.SetContentText("Toque para parar de stremear su media"); nBuilder.SetOngoing(true); // nBuilder.SetContentIntent(pendingIntent2); nBuilder.SetStyle(textoo); nBuilder.SetSmallIcon(Resource.Drawable.antena); nBuilder.SetColor(Android.Graphics.Color.ParseColor("#ce2c2b")); nBuilder.AddAction(accion); nBuilder.AddAction(accion2); Notification notification = nBuilder.Build(); StartForeground(193423456, notification); base.OnCreate(); // descargar(intent.GetStringExtra("path"), intent.GetStringExtra("archivo"), intent.GetStringExtra("titulo"), intent.GetStringExtra("link")); }