Ejemplo n.º 1
0
        public void Notify(string title, string message, string itemId)
        {
            var context      = Application.Context;
            var resultIntent = new Intent(context, typeof(MainActivity));

            resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);

            var pending = PendingIntent.GetActivity(context, 0,
                                                    resultIntent,
                                                    PendingIntentFlags.CancelCurrent);

            var pickedUpIntent = new Intent("PickedUp");

            pickedUpIntent.PutExtra("itemId", itemId);
            var pendingPickedUpIntent = PendingIntent.GetBroadcast(context, 0, pickedUpIntent, PendingIntentFlags.CancelCurrent);
            var builder =
                new Notification.Builder(context)
                .SetContentTitle(title)
                .SetContentText(message)
                .SetSmallIcon(Resource.Drawable.icon)
                .SetDefaults(NotificationDefaults.All)
                .SetVisibility(NotificationVisibility.Public);

            builder.SetContentIntent(pending);
            var pickedUpAction = new Notification.Action(Resource.Drawable.abc_btn_check_material, "Picked Up", pendingPickedUpIntent);

            builder.AddAction(pickedUpAction);

            var notification = builder.Build();

            notification.Flags = NotificationFlags.AutoCancel;
            var manager = NotificationManager.FromContext(context);

            manager.Notify(1337, notification);
        }
        private void BuildNotification(Notification.Action action)
        {
            var style  = new Notification.MediaStyle();
            var intent = new Intent(ApplicationContext, typeof(MediaPlayerService));

            intent.SetAction(ActionStop);
            var pendingIntent = PendingIntent.GetService(ApplicationContext, 1, intent, 0);

            Notification.Builder builder = new Notification.Builder(this)
                                           .SetSmallIcon(Resource.Mipmap.Icon)
                                           .SetContentTitle("Lock screen example")
                                           .SetContentText("Artist name")
                                           .SetDeleteIntent(pendingIntent)
                                           .SetStyle(style);

            builder.AddAction(GenerateAction(Android.Resource.Drawable.IcMediaPrevious, "Previous", ActionPrevious));
            builder.AddAction(GenerateAction(Android.Resource.Drawable.IcMediaRew, "Rew", ActionRewind));
            builder.AddAction(action);
            builder.AddAction(GenerateAction(Android.Resource.Drawable.IcMediaFf, "Fast forward", ActionFastForward));
            builder.AddAction(GenerateAction(Android.Resource.Drawable.IcMediaNext, "Next", ActionNext));

            style.SetShowActionsInCompactView(0, 2, 4);
            style.SetMediaSession(mediaSession.SessionToken);

            var notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Notify(1, 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);
            }
        }
Ejemplo n.º 4
0
        private static void CreateNotificationMediaActions()
        {
            Intent stopIntent = new Intent("ACTION_MEDIA_BUTTON");

            stopIntent.SetClass(Application.Context, typeof(BluetoothRemoteControlReciever));
            stopIntent.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.MediaStop));
            PendingIntent stopPendingIntent = PendingIntent.GetBroadcast(Application.Context, 3, stopIntent, PendingIntentFlags.UpdateCurrent);

            Notification.Action stopAction = new Notification.Action(Resource.Drawable.ic_cancel_blue, string.Empty, stopPendingIntent);
            builder.AddAction(stopAction);
        }
Ejemplo n.º 5
0
        public override void OnReceive(Context context, Intent intent)
        {
            // set next alarm
            //var repetitionIntent = new Intent(context, typeof(AlarmReceiver));
            //var source = PendingIntent.GetBroadcast(context, 0, intent, 0);
            //var am = (AlarmManager)Android.App.Application.Context.GetSystemService(Context.AlarmService);
            //var calendar = DateTime.Parse(intent.GetStringExtra(Intent.ExtraText)).AddMinutes(1);

            //DateTime dtBasis = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            //am.SetExactAndAllowWhileIdle(AlarmType.RtcWakeup, (long)calendar.ToUniversalTime().Subtract(dtBasis).TotalMilliseconds, source);


            int notificationId = 001;
            // The channel ID of the notification.
            String id = "my_channel_01";

            // sound the alarm
            var alert   = RingtoneManager.GetDefaultUri(RingtoneType.Alarm);
            var _mediap = MediaPlayer.Create(context, alert);

            AudioManager audioM = (AudioManager)context.GetSystemService(Context.AudioService);

            if (audioM.GetStreamVolume(Stream.Alarm) != 0)
            {
                _mediap.Start();

                // wait 5 sec... then stop the player.
                new Handler().PostDelayed(() =>
                {
                    _mediap.Stop();
                }, 5000);//millisec.
            }

            NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);

            Intent        respondIntent        = new Intent(context, typeof(NotificationService));
            PendingIntent respontPendingIntent = PendingIntent.GetService(context, 0, respondIntent, 0);

            Notification.Action action = new Notification.Action(Resource.Drawable.generic_confirmation, "confirm", respontPendingIntent);

            Intent        snoozeIntent        = new Intent(context, typeof(SnoozeService));
            PendingIntent snoozePendingIntent = PendingIntent.GetService(context, 0, snoozeIntent, 0);

            Notification.Action snooze = new Notification.Action(Resource.Drawable.generic_confirmation, "snooze", snoozePendingIntent);
            var noti = new Notification.Builder(context)
                       .SetContentTitle("Title").SetContentText("content text")
                       .SetSmallIcon(Resource.Drawable.pills)
                       .AddAction(action)
                       .AddAction(snooze);


            notificationManager.Notify(notificationId, noti.Build());
        }
Ejemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.RecipeView);

            var request = MvxViewModelRequest <RecipeViewModel> .GetDefaultRequest();

            var translator = Mvx.Resolve <IMvxAndroidViewModelRequestTranslator>();

            var intent = translator.GetIntentFor(request);

            intent.PutExtra("life34", "halflife");


            var pending = PendingIntent.GetActivity(
                this, 0, intent, 0);

            Notification.Action alarm_action =
                new Notification.Action(Resource.Drawable.ic_add, "Silence alarm", pending);

            var request2 = MvxViewModelRequest <RecipeViewModel> .GetDefaultRequest();

            var intent2 = translator.GetIntentFor(request2);

            intent2.PutExtra("life-in-another-intent", "counter-strike");


            var pending2 = PendingIntent.GetActivity(
                this, 1, intent2, 0);

            Notification.Action action2 =
                new Notification.Action(Resource.Drawable.ic_save, "Extend", pending2);

            Notification.Builder builder =
                new Notification.Builder(this.ApplicationContext)
                .SetSmallIcon(Resource.Drawable.ic_pause)
                .SetContentTitle("My notification")
                .SetContentText("Hello World!")
                .AddAction(alarm_action)
                .AddAction(action2)
//                .SetContentIntent(pending2)
//                .SetAutoCancel(true) // clears the notification on click
                .SetVisibility(NotificationVisibility.Public); // makes the notification visible on lock screen

            Notification notification        = builder.Build();
            var          notificationManager = (NotificationManager)
                                               this.ApplicationContext.GetSystemService(Context.NotificationService);

            notificationManager.Notify(0, builder.Build());

            // https://developer.xamarin.com/guides/android/application_fundamentals/notifications/local_notifications_in_android/
        }
Ejemplo n.º 7
0
        public void Popup(string Message, Type type)
        {
            this.Opacity       = 0.0;
            this.StartPosition = FormStartPosition.Manual;
            string fname;

            for (int i = 1; i < 10; i++)
            {
                fname = "alert" + i.ToString();
                Notification frm = (Notification)Application.OpenForms[fname];
                if (frm == null)
                {
                    this.Name     = fname;
                    this.x        = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15;
                    this.y        = Screen.PrimaryScreen.WorkingArea.Height - (this.Height * i);
                    this.Location = new Point(this.x, this.y);
                    break;
                }
            }
            this.x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5;
            this.Show();
            switch (type)
            {
            case Type.Success:
                pb.Image       = Properties.Resources.Success;
                this.BackColor = Color.SeaGreen;
                break;

            case Type.Warning:
                pb.Image       = Properties.Resources.Warning;
                this.BackColor = Color.DarkOrange;
                break;

            case Type.Error:
                pb.Image       = Properties.Resources.cancel;
                this.BackColor = Color.DarkRed;
                break;

            case Type.Info:
                pb.Image       = Properties.Resources.Info;
                this.BackColor = Color.RoyalBlue;
                break;

            default:
                break;
            }

            this.lblMessage.Text = Message;
            this.action          = Action.Start;
            timer1.Interval      = 1;
            this.timer1.Start();
        }
        /// <summary>
        /// Posts a local notification for the given geofence ID, with an option to check in
        /// </summary>
        /// <param name="geofenceId">The geodence id that the user has triggered</param>
        /// <param name="dataItemUri">The Uri for the DataItem that triggered this notification. Used to delete this DataItem
        /// when the notification is dismissed</param>
        void PostNotificationForGeofenceId(String geofenceId, Android.Net.Uri dataItemUri)
        {
            // Use the geofenceId to determine the title and background of the check-in notification.
            // A SpannableString is used for the notification title for resizing capabilities
            SpannableString checkInTitle;
            Bitmap          notificationBackground;

            if (Constants.ANDROID_BUILDING_ID.Equals(geofenceId))
            {
                checkInTitle           = new SpannableString(GetText(Resource.String.android_building_title));
                notificationBackground = BitmapFactory.DecodeResource(Resources, Resource.Drawable.android_building);
            }
            else if (Constants.YERBA_BUENA_ID.Equals(geofenceId))
            {
                checkInTitle           = new SpannableString(GetText(Resource.String.yerba_buena_title));
                notificationBackground = BitmapFactory.DecodeResource(Resources, Resource.Drawable.yerba_buena);
            }
            else
            {
                Log.Error(Constants.TAG, "Unrecognized geofence id: " + geofenceId);
                return;
            }
            // Resize the title to avoid truncation
            checkInTitle.SetSpan(new RelativeSizeSpan(0.8f), 0, checkInTitle.Length(), SpanTypes.PointMark);

            Intent        checkInOperation = new Intent(this, typeof(CheckInAndDeleteDataItemsService)).SetData(dataItemUri);
            PendingIntent checkInIntent    = PendingIntent.GetService(this, 0, checkInOperation.SetAction(Constants.ACTION_CHECK_IN),
                                                                      PendingIntentFlags.CancelCurrent);
            PendingIntent deleteDataItemIntent = PendingIntent.GetService(this, 0, checkInOperation.SetAction(Constants.ACTION_DELETE_DATA_ITEM),
                                                                          PendingIntentFlags.CancelCurrent);
            // This action will be embedded into the notification
            var checkInAction = new Notification.Action(Resource.Drawable.ic_action_check_in,
                                                        GetText(Resource.String.check_in_prompt), checkInIntent);

            Notification notification = new Notification.Builder(this)
                                        .SetContentTitle(checkInTitle)
                                        .SetContentText(GetText(Resource.String.check_in_prompt))
                                        .SetSmallIcon(Resource.Drawable.ic_launcher)
                                        .SetDeleteIntent(deleteDataItemIntent)
                                        .Extend(new Notification.WearableExtender()
                                                .SetBackground(notificationBackground)
                                                .AddAction(checkInAction)
                                                .SetContentAction(0)
                                                .SetHintHideIcon(true))
                                        .SetLocalOnly(true)
                                        .Build();

            GetSystemService(NotificationService).JavaCast <NotificationManager> ().Notify(Constants.NOTIFICATION_ID, notification);
        }
        private void CreateActions()
        {
            var context = Application.Context;

            var previousIntent        = new Intent(ButtonEvents.AudioControlsPrevious);
            var previousPendingIntent = PendingIntent.GetBroadcast(context, 1, previousIntent, 0);

            previousAction = new Notification.Action(Android.Resource.Drawable.IcMediaPrevious, string.Empty, previousPendingIntent);

            var nextIntent        = new Intent(ButtonEvents.AudioControlsNext);
            var nextPendingIntent = PendingIntent.GetBroadcast(context, 1, nextIntent, 0);

            nextAction = new Notification.Action(Android.Resource.Drawable.IcMediaNext, string.Empty, nextPendingIntent);

            var skipBackwardIntent        = new Intent(ButtonEvents.AudioControlsSkipBackward);
            var skipBackwardPendingIntent = PendingIntent.GetBroadcast(context, 1, skipBackwardIntent, 0);

            skipBackwardAction = new Notification.Action(Android.Resource.Drawable.IcMediaRew, string.Empty, skipBackwardPendingIntent);

            var skipForwardIntent        = new Intent(ButtonEvents.AudioControlsSkipForward);
            var skipForwardPendingIntent = PendingIntent.GetBroadcast(context, 1, skipForwardIntent, 0);

            skipForwardAction = new Notification.Action(Android.Resource.Drawable.IcMediaFf, string.Empty, skipForwardPendingIntent);

            var playIntent        = new Intent(ButtonEvents.AudioControlsPlay);
            var playPendingIntent = PendingIntent.GetBroadcast(context, 1, playIntent, 0);

            playAction = new Notification.Action(Android.Resource.Drawable.IcMediaPlay, string.Empty, playPendingIntent);

            var pauseIntent        = new Intent(ButtonEvents.AudioControlsPause);
            var pausePendingIntent = PendingIntent.GetBroadcast(context, 1, pauseIntent, 0);

            pauseAction = new Notification.Action(Android.Resource.Drawable.IcMediaPause, string.Empty, pausePendingIntent);

            var destroyIntent        = new Intent(ButtonEvents.AudioControlsDestroy);
            var destroyPendingIntent = PendingIntent.GetBroadcast(context, 1, destroyIntent, 0);

            destroyAction = new Notification.Action(Android.Resource.Drawable.IcMenuCloseClearCancel, string.Empty, destroyPendingIntent);
        }
Ejemplo n.º 10
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            switch (this.action)
            {
            case Action.Wait:
                timer1.Interval = 5000;
                action          = Action.Close;
                break;

            case Action.Start:
                timer1.Interval = 1;
                this.Opacity   += 0.1;
                if (this.x < this.Location.X)
                {
                    this.Left--;
                }
                else
                {
                    if (this.Opacity == 1.0)
                    {
                        action = Action.Wait;
                    }
                }
                break;

            case Action.Close:
                timer1.Interval = 1;
                this.Opacity   -= 0.1;
                this.Left      -= 3;
                if (base.Opacity == 0.0)
                {
                    this.Close();
                }
                break;

            default:
                break;
            }
        }
        private void CreateActions()
        {
            var context = Application.Context;

            var previousIntent        = new Intent("music-controls-previous");
            var previousPendingIntent = PendingIntent.GetBroadcast(context, 1, previousIntent, 0);

            previousAction = new Notification.Action(Android.Resource.Drawable.IcMediaPrevious, "", previousPendingIntent);

            var nextIntent        = new Intent("music-controls-next");
            var nextPendingIntent = PendingIntent.GetBroadcast(context, 1, nextIntent, 0);

            nextAction = new Notification.Action(Android.Resource.Drawable.IcMediaNext, "", nextPendingIntent);

            var skipBackwardIntent        = new Intent("music-controls-skip-backward");
            var skipBackwardPendingIntent = PendingIntent.GetBroadcast(context, 1, skipBackwardIntent, 0);

            skipBackwardAction = new Notification.Action(Android.Resource.Drawable.IcMediaRew, "", skipBackwardPendingIntent);

            var skipForwardIntent        = new Intent("music-controls-skip-forward");
            var skipForwardPendingIntent = PendingIntent.GetBroadcast(context, 1, skipForwardIntent, 0);

            skipForwardAction = new Notification.Action(Android.Resource.Drawable.IcMediaFf, "", skipForwardPendingIntent);

            var playIntent        = new Intent("music-controls-play");
            var playPendingIntent = PendingIntent.GetBroadcast(context, 1, playIntent, 0);

            playAction = new Notification.Action(Android.Resource.Drawable.IcMediaPlay, "", playPendingIntent);

            var pauseIntent        = new Intent("music-controls-pause");
            var pausePendingIntent = PendingIntent.GetBroadcast(context, 1, pauseIntent, 0);

            pauseAction = new Notification.Action(Android.Resource.Drawable.IcMediaPause, "", pausePendingIntent);

            var destroyIntent        = new Intent("music-controls-destroy");
            var destroyPendingIntent = PendingIntent.GetBroadcast(context, 1, destroyIntent, 0);

            destroyAction = new Notification.Action(Android.Resource.Drawable.IcMenuCloseClearCancel, "", destroyPendingIntent);
        }
		/// <summary>
		/// Posts a local notification for the given geofence ID, with an option to check in
		/// </summary>
		/// <param name="geofenceId">The geodence id that the user has triggered</param>
		/// <param name="dataItemUri">The Uri for the DataItem that triggered this notification. Used to delete this DataItem
		/// when the notification is dismissed</param>
		void PostNotificationForGeofenceId(String geofenceId, Android.Net.Uri dataItemUri) {
			// Use the geofenceId to determine the title and background of the check-in notification.
			// A SpannableString is used for the notification title for resizing capabilities
			SpannableString checkInTitle;
			Bitmap notificationBackground;
			if (Constants.ANDROID_BUILDING_ID.Equals (geofenceId)) {
				checkInTitle = new SpannableString (GetText (Resource.String.android_building_title));
				notificationBackground = BitmapFactory.DecodeResource (Resources, Resource.Drawable.android_building);
			} else if (Constants.YERBA_BUENA_ID.Equals (geofenceId)) {
				checkInTitle = new SpannableString (GetText (Resource.String.yerba_buena_title));
				notificationBackground = BitmapFactory.DecodeResource (Resources, Resource.Drawable.yerba_buena);
			} else {
				Log.Error (Constants.TAG, "Unrecognized geofence id: " + geofenceId);
				return;
			}
			// Resize the title to avoid truncation
			checkInTitle.SetSpan (new RelativeSizeSpan (0.8f), 0, checkInTitle.Length(), SpanTypes.PointMark);

			Intent checkInOperation = new Intent (this, typeof(CheckInAndDeleteDataItemsService)).SetData (dataItemUri);
			PendingIntent checkInIntent = PendingIntent.GetService (this, 0, checkInOperation.SetAction (Constants.ACTION_CHECK_IN),
				                              PendingIntentFlags.CancelCurrent);
			PendingIntent deleteDataItemIntent = PendingIntent.GetService (this, 0, checkInOperation.SetAction (Constants.ACTION_DELETE_DATA_ITEM),
				                                     PendingIntentFlags.CancelCurrent);
			// This action will be embedded into the notification
			var checkInAction = new Notification.Action (Resource.Drawable.ic_action_check_in,
				                       GetText (Resource.String.check_in_prompt), checkInIntent);

			Notification notification = new Notification.Builder (this)
				.SetContentTitle (checkInTitle)
				.SetContentText (GetText (Resource.String.check_in_prompt))
				.SetSmallIcon (Resource.Drawable.ic_launcher)
				.SetDeleteIntent (deleteDataItemIntent)
				.Extend (new Notification.WearableExtender ()
					.SetBackground (notificationBackground)
					.AddAction (checkInAction)
					.SetContentAction (0)
					.SetHintHideIcon (true))
				.SetLocalOnly (true)
				.Build ();

			GetSystemService (NotificationService).JavaCast<NotificationManager> ().Notify (Constants.NOTIFICATION_ID, notification);
		}
Ejemplo n.º 13
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     timer1.Interval = 1;
     action          = Action.Close;
 }
        public void mostrarnotificacion()
        {
            var listapending = listapendingintents();


            RemoteViews contentView = new RemoteViews(PackageName, Resource.Layout.layoutminiplayeronline);

            if (linkactual.Trim().Length > 1)
            {
                try
                {
                    contentView.SetImageViewBitmap(Resource.Id.imageView1, ImageHelper.GetRoundedShape(GetImageBitmapFromUrl(linkactual)));
                    contentView.SetImageViewBitmap(Resource.Id.fondo1, ImageHelper.CreateBlurredImageFromUrl(this, 20, linkactual));
                }
                catch (Exception)
                {
                }
            }
            contentView.SetOnClickPendingIntent(Resource.Id.imageView1, listapending[5]);
            contentView.SetTextViewText(Resource.Id.textView1, tituloactual);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView2, listapending[0]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView4, listapending[1]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView3, listapending[2]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView6, listapending[3]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView5, listapending[4]);


            /*
             *
             * 1-playpause
             * 2-siguiente
             * 3-anterior
             * 4-adelantar
             * 5-atrazar
             *
             */

            Notification.Action accion1 = new Notification.Action(Resource.Drawable.playpause, "Playpause", listapending[0]);
            Notification.Action accion2 = new Notification.Action(Resource.Drawable.skipnext, "Siguiente", listapending[1]);
            Notification.Action accion3 = new Notification.Action(Resource.Drawable.skipprevious, "Anterior", listapending[2]);
            Notification.Action accion4 = new Notification.Action(Resource.Drawable.skipforward, "adelantar", listapending[3]);
            Notification.Action accion5 = new Notification.Action(Resource.Drawable.skipbackward, "atrazar", listapending[4]);

#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            var nBuilder = new Notification.Builder(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            Notification.MediaStyle estilo = new Notification.MediaStyle();
            if (Mainmenu.gettearinstancia() != null)
            {
                //  estilo.SetMediaSession(mainmenu.gettearinstancia().mSession.SessionToken);

                estilo.SetShowActionsInCompactView(1, 2, 3);
            }
            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
#pragma warning disable 414
                try {
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                    nBuilder.SetContent(contentView);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                }
                catch (Exception) {
                }

#pragma warning restore 414
            }
            else
            {
                nBuilder.SetStyle(estilo);
                nBuilder.SetLargeIcon(ImageHelper.GetImageBitmapFromUrl(linkactual));
                nBuilder.SetContentTitle(tituloactual);
                nBuilder.SetContentText("Desde: " + Mainmenu.gettearinstancia().devicename);
                nBuilder.AddAction(accion5);
                nBuilder.AddAction(accion3);
                nBuilder.AddAction(accion1);
                nBuilder.AddAction(accion2);
                nBuilder.AddAction(accion4);
                nBuilder.SetContentIntent(listapending[5]);
                nBuilder.SetColor(Android.Graphics.Color.ParseColor("#ce2c2b"));
            }
            nBuilder.SetOngoing(true);

            nBuilder.SetSmallIcon(Resource.Drawable.play);

            Notification notification = nBuilder.Build();
            StartForeground(19248736, notification);
        }
Ejemplo n.º 15
0
 public OpenAction(Notification.Action action)
 {
     this.action = action;
 }
Ejemplo n.º 16
0
 public OpenAction(Notification.Action action)
 {
     this.action = action;
     //var test1 = action.Extras;
     //var test2 = action.Extras.KeySet();
 }
        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"));
        }
        public void mostrarnotificacion()
        {
            List <PendingIntent> listapending = listapendingintents();

            RemoteViews contentView = new RemoteViews(PackageName, Resource.Layout.layoutminiplayer);

            if (linkactual.Trim().Length > 1)
            {
                try
                {
                    // contentView.SetImageViewBitmap(Resource.Id.imageView1, playeroffline.gettearinstancia().imageneses.First(info => info.GenerationId == playeroffline.gettearinstancia().diccionario[tituloactual]));
                    contentView.SetImageViewBitmap(Resource.Id.fondo1, ImageHelper.CreateBlurredImageFromPortrait(this, 20, linkactual));
                }
                catch (Exception) {
                }

                ///   contentView.SetImageViewBitmap(Resource.Id.fondo1, clasesettings.CreateBlurredImageoffline(this, 20, linkactual));
            }
            contentView.SetTextViewText(Resource.Id.textView1, tituloactual);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView1, listapending[5]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView2, listapending[0]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView4, listapending[1]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView3, listapending[2]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView6, listapending[3]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView5, listapending[4]);



            Notification.Action accion1 = new Notification.Action(Resource.Drawable.playpause, "Playpause", listapending[0]);
            Notification.Action accion2 = new Notification.Action(Resource.Drawable.skipnext, "Siguiente", listapending[1]);
            Notification.Action accion3 = new Notification.Action(Resource.Drawable.skipprevious, "Anterior", listapending[2]);
            Notification.Action accion4 = new Notification.Action(Resource.Drawable.skipforward, "adelantar", listapending[3]);
            Notification.Action accion5 = new Notification.Action(Resource.Drawable.skipbackward, "atrazar", listapending[4]);

            /*
             *
             * 1-playpause
             * 2-siguiente
             * 3-anterior
             * 4-adelantar
             * 5-atrazar
             *
             */



            Notification.MediaStyle estilo = new Notification.MediaStyle();
            if (playeroffline.gettearinstancia() != null)
            {
                estilo.SetMediaSession(playeroffline.gettearinstancia().mSession.SessionToken);

                estilo.SetShowActionsInCompactView(1, 2, 3);
            }


#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            var nBuilder = new Notification.Builder(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
#pragma warning disable 414
                try
                {
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                    nBuilder.SetContent(contentView);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                }
                catch (Exception) {
                }

#pragma warning restore 414
            }
            else
            {
                nBuilder.SetStyle(estilo);
                nBuilder.SetLargeIcon(GetImageBitmapFromUrl(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/portraits/" + playeroffline.gettearinstancia().linkeses[playeroffline.gettearinstancia().nombreses.IndexOf(tituloactual)].Split('=')[1]));
                nBuilder.SetContentTitle(tituloactual);

                nBuilder.SetContentText(playeroffline.gettearinstancia().linkeses[playeroffline.gettearinstancia().nombreses.IndexOf(tituloactual)]);
                nBuilder.AddAction(accion5);
                nBuilder.AddAction(accion3);
                nBuilder.AddAction(accion1);
                nBuilder.AddAction(accion2);
                nBuilder.AddAction(accion4);
                nBuilder.SetContentIntent(listapending[5]);
                nBuilder.SetColor(Android.Graphics.Color.ParseColor("#ce2c2b"));

                //  nBuilder.AddAction()
            }

            nBuilder.SetOngoing(true);
            nBuilder.SetSmallIcon(Resource.Drawable.play);
            Notification notification = nBuilder.Build();
            StartForeground(19248736, notification);
            listapending.Clear();
        }
Ejemplo n.º 19
0
        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);
            }
        }