public override void OnListenerConnected()
        {
            activeMediaSessionsListener = new ActiveMediaSessionsListener();
            //RemoteController Lollipop and Beyond Implementation
            mediaSessionManager = (MediaSessionManager)GetSystemService(MediaSessionService);

            //Listener para Sesiones
            using (var h = new Handler(Looper.MainLooper)) //Using UI Thread because seems to crash in some devices.
                h.Post(() =>
                {
                    try
                    {
                        mediaSessionManager.AddOnActiveSessionsChangedListener(activeMediaSessionsListener, new ComponentName(this, Java.Lang.Class.FromType(typeof(Catcher))));
                        Log.Info("LiveDisplay", "Added Media Sess. Changed Listener");
                    }
                    catch
                    {
                        Log.Info("LiveDisplay", "Failed to register Media Session Callback");
                    }
                });

            SubscribeToEvents();
            RegisterReceivers();
            //This is for blocking Headsup notifications in Android Marshmallow and on, it does not work though LOL, stupid Android.
            //NotificationManager notificationManager = GetSystemService(NotificationService) as NotificationManager;
            //notificationManager.NotificationPolicy = new NotificationManager.Policy(NotificationPriorityCategory.Alarms | NotificationPriorityCategory.Calls | NotificationPriorityCategory.Events | NotificationPriorityCategory.Media | NotificationPriorityCategory.Messages | NotificationPriorityCategory.Reminders | NotificationPriorityCategory.RepeatCallers | NotificationPriorityCategory.System | NotificationPriorityCategory.RepeatCallers, NotificationPrioritySenders.Starred, NotificationPrioritySenders.Starred);
            //notificationManager.SetInterruptionFilter(InterruptionFilter.None);
            RetrieveNotificationFromStatusBar();
        }
Exemple #2
0
        public override void OnListenerConnected()
        {
            activeMediaSessionsListener = new ActiveMediaSessionsListener();
            //RemoteController Lollipop and Beyond Implementation
            mediaSessionManager = (MediaSessionManager)GetSystemService(MediaSessionService);

            //Listener para Sesiones
            using (var h = new Handler(Looper.MainLooper)) //Using UI Thread because seems to crash in some devices.
                h.Post(() =>
                {
                    mediaSessionManager.AddOnActiveSessionsChangedListener(activeMediaSessionsListener, new ComponentName(this, Java.Lang.Class.FromType(typeof(Catcher))));
                    Log.Info("LiveDisplay", "Added Media Sess. Changed Listener");
                });

            SubscribeToEvents();
            RegisterReceivers();
            RetrieveNotificationFromStatusBar();
        }