Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

[Xamarin.Android] NotificationListenerService Issue

CarbongripCarbongrip USMember ✭✭
edited April 2017 in Xamarin.Android

Hello everyone,

I'm having an issue with my NotificationListenerService, it doesn't seem to be connecting to listener. My service is currently only calling OnCreate for some reason as I do receive "service running!".

My Code:


using System;
using System.Collections.Generic;

using Android.App;
using Android.Service.Notification;
using Android.Util;

namespace NotificationPushAndroid
    [Service(Label = "NotificationListener", Permission = "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE")]
    class NotificationListener : NotificationListenerService
        static readonly string TAG = "X:" + typeof(NotificationListener).Name;

        public override void OnCreate()
            Log.Debug(TAG,"service running!");

        public override void OnListenerConnected()

            Log.Debug(TAG, "Listener Connected!");
            List<string> l = new List<string>();

            foreach (StatusBarNotification sbn in GetActiveNotifications())
                Log.Debug(TAG, sbn.Notification.TickerText.ToString());


        public override void OnNotificationPosted(StatusBarNotification sbn)
            Console.WriteLine("Notification Posted!");
            Log.Debug(TAG,"ID :" + sbn.Id + "t" + sbn.Notification.TickerText + "t" + sbn.PackageName);


    using System;

    using Android;
    using Android.App;
    using Android.Content;
    using Android.Widget;
    using Android.OS;
    using Android.Content.PM;
    using Android.Support.Design.Widget;
    using Android.Support.V4.App;

    namespace NotificationPushAndroid
        [Activity(Label = "NotificationPushAndroid", MainLauncher = true, Icon = "@drawable/icon", Theme = "@style/Theme.AppCompat")]
        public class MainActivity : Activity
            protected override void OnCreate(Bundle bundle)

                // Set our view from the "main" layout resource
                SetContentView (Resource.Layout.Main);

                Button button1 = FindViewById<Button>(Resource.Id.button1);
                button1.Click += button1_Clicked;

                StartService(new Intent(this, typeof(NotificationListener)));



<?xml version="1.0" encoding="utf-8"?>

Notification Access Enabled


  • CarbongripCarbongrip USMember ✭✭

    Manifest didn't post good here it is again...

    <?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="" package="NotificationPushAndroid.NotificationPushAndroid" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
            <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23" />
            <uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" />
            <application android:label="NotificationPushAndroid">
            <service android:name=".NotificationListener"
                <action android:name="android.service.notification.NotificationListenerService" />
Sign In or Register to comment.